authmaterial

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UpgradeStagePrepared         = "prepared"
	UpgradeStageCookiesRewrapped = "cookies_rewrapped"
	UpgradeStageDataRewrapped    = "data_rewrapped"
)
View Source
const (
	// AuthPasswordMinLength defines the minimum web auth password length.
	AuthPasswordMinLength = 12
)
View Source
const (
	WebAuthFileName = "web-auth.json"
)

Variables

View Source
var ErrUnavailable = errors.New("web auth material unavailable")

Functions

func AuthFilePath

func AuthFilePath(dbPath string) string

func BootstrapAuthFile

func BootstrapAuthFile(dbPath string, username string, password string) error

func GenerateSeed

func GenerateSeed() (string, error)

func HashPassword

func HashPassword(password string) (string, error)

func VerifyPassword

func VerifyPassword(password string, encoded string) bool

func VerifyPasswordWithUpgrade

func VerifyPasswordWithUpgrade(password string, encoded string) (bool, bool)

Types

type Material

type Material struct {
	Username               string `json:"username"`
	PasswordHash           string `json:"password_hash"`
	EncryptionKeySeed      string `json:"encryption_key_seed,omitempty"`
	AllowUnencryptedExport bool   `json:"allow_unencrypted_export,omitempty"`
}

func LoadFromDBPath

func LoadFromDBPath(dbPath string) (Material, error)

func (Material) IsUsable

func (m Material) IsUsable() bool

func (Material) LegacyHelper

func (m Material) LegacyHelper() (string, string, error)

func (Material) PrimaryHelper

func (m Material) PrimaryHelper() (string, string, error)

func (Material) StableHelper

func (m Material) StableHelper() (string, string, bool)

func (Material) WithSeed

func (m Material) WithSeed(seed string) Material

type PendingUpgrade

type PendingUpgrade struct {
	Stage     string    `json:"stage"`
	Target    Record    `json:"target"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Record

type Record struct {
	Username                string          `json:"username"`
	PasswordHash            string          `json:"password_hash"`
	EncryptionKeySeed       string          `json:"encryption_key_seed,omitempty"`
	AllowUnencryptedExport  bool            `json:"allow_unencrypted_export,omitempty"`
	BrowseRoot              string          `json:"browse_root,omitempty"`
	AllowUnrestrictedBrowse bool            `json:"allow_unrestricted_browse,omitempty"`
	PendingUpgrade          *PendingUpgrade `json:"pending_upgrade,omitempty"`
	CreatedAt               time.Time       `json:"created_at"`
}

func LoadRecordFromDBPath

func LoadRecordFromDBPath(dbPath string) (Record, error)

func (Record) AuthMaterial

func (r Record) AuthMaterial() Material

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(dbPath string) (*Store, error)

func (*Store) AdvancePendingUpgrade

func (s *Store) AdvancePendingUpgrade(username string, stage string) error

func (*Store) BeginPendingUpgrade

func (s *Store) BeginPendingUpgrade(current Record, target Record) error

func (*Store) Bootstrap

func (s *Store) Bootstrap(username string, password string) error

func (*Store) ClearPendingUpgrade

func (s *Store) ClearPendingUpgrade(username string) error

func (*Store) Exists

func (s *Store) Exists() (bool, error)

func (*Store) FinalizePendingUpgrade

func (s *Store) FinalizePendingUpgrade(username string) (Record, error)

func (*Store) Load

func (s *Store) Load() (Record, error)

func (*Store) UpdatePasswordHash

func (s *Store) UpdatePasswordHash(username string, passwordHash string) error

func (*Store) UpdateRecord

func (s *Store) UpdateRecord(updated Record) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL