Documentation
¶
Overview ¶
Package owner ties an authama home to the person and machine it belongs to.
Three things, all optional and all off until `authama owner init`:
- A sealing key, kept by the OS for the user (macOS Keychain, the Secret Service on Linux, DPAPI on Windows, else an owner-only file). It never leaves the store except into this process's memory.
- A seal over the state files (core/seal), remade after every operation authama performs, so a file changed by anything else, or a home copied to another account or machine, is named the next time authama runs.
- A PIN or passphrase, hashed (core/pin), that the web UI asks for at sign-in and again before any change, and that the command line asks for before reading a secret or making a destructive change. A fingerprint can stand in for it where the platform has a reader authama can drive (see biometric_*.go).
Resetting a forgotten PIN needs no old PIN, only this account on this machine: the reset must reach the sealing key in the user's own credential store, and the binding must match. That is the proof of the OS account.
Index ¶
- Constants
- Variables
- func BiometricAvailable() (bool, string)
- func CheckPIN(p paths.Paths, candidate string, now time.Time) error
- func ConfigPath(p paths.Paths) string
- func CurrentBinding() (seal.Binding, error)
- func Forget(p paths.Paths) error
- func MachineID() (string, error)
- func Platform() string
- func Recoverable(p paths.Paths) error
- func RemovePIN(p paths.Paths, current string, now time.Time) error
- func Reseal(p paths.Paths, now time.Time) error
- func ResetPIN(p paths.Paths, next string, now time.Time) error
- func SealPath(p paths.Paths) string
- func SealedFiles(p paths.Paths) map[string]string
- func SetBiometric(p paths.Paths, on bool, now time.Time) error
- func SetPIN(p paths.Paths, current, next string, now time.Time) error
- func VerifyBiometric(ctx context.Context) error
- type Config
- type LockedError
- type State
- type Store
Constants ¶
const ( FreeAttempts = 5 LockoutBase = 30 * time.Second LockoutMax = 15 * time.Minute )
FreeAttempts is how many wrong PINs in a row are allowed before each further one waits; the wait doubles from LockoutBase up to LockoutMax.
const ( StoreFile = "file" StoreKeychain = "keychain" StoreSecret = "secret-service" StoreDPAPI = "dpapi" )
Store names.
const ConfigVersion = 1
ConfigVersion is owner.json's format.
const StoreEnv = envnames.OwnerStore
StoreEnv chooses the store: "file" forces the owner-only file, for a machine with no keyring session (a server over ssh, a container).
Variables ¶
var ( ErrNotSetUp = errors.New("this home is not bound to an owner yet; run `authama owner init`") ErrSetUp = errors.New("this home is already bound to an owner; `authama owner status` shows it") ErrNoPIN = errors.New("no PIN is set; `authama owner pin set` sets one") ErrWrongPIN = errors.New("that PIN is not the one set for this home") ErrElsewhere = errors.New("this home was bound on another account or machine; " + "`authama owner forget` and `authama owner init` bind it here") )
Errors a caller tells apart.
var ErrNoKey = errors.New("no sealing key is stored")
ErrNoKey is a store that holds no key for this home.
Functions ¶
func BiometricAvailable ¶
BiometricAvailable reports whether fprintd can verify a fingerprint for this user: the tool is installed and a finger is enrolled.
func CheckPIN ¶
CheckPIN checks candidate against the PIN set for the home. Wrong answers are counted across processes, in the state home, so restarting the server or the command does not reset the wait; a right one clears the count, and rehashes a PIN stored at a lower cost than today's.
func CurrentBinding ¶
CurrentBinding is the account and machine this process runs as.
func Forget ¶
Forget unbinds the home: the key leaves the store, owner.json and the seal are removed, and with them the PIN. The state files themselves are kept.
func MachineID ¶
MachineID is systemd's /etc/machine-id, or D-Bus's copy of it on a system without systemd: stable across reboots, and different on every install.
func Recoverable ¶
Recoverable reports why a forgotten PIN could not be reset here, or nil: the reset reads the sealing key from this account's store on the bound machine, so both must hold before a PIN is set, or setting one could lock the owner out for good.
func Reseal ¶
Reseal remakes the seal from the files as they are now. authama calls it after an operation it performed; `authama owner reseal` calls it to accept a change made outside authama. A home with no owner is left alone.
func ResetPIN ¶
ResetPIN replaces a forgotten PIN. No old PIN: reaching the key in this account's credential store, on the bound machine, is the proof.
func SealedFiles ¶
SealedFiles names the files a seal covers: everything authama keeps that a change behind its back would make it act on, or that holds a credential. The history database is not here: it changes on every read of a secret and carries its own content hashes.
func SetBiometric ¶
SetBiometric turns fingerprint unlock on or off. It needs a PIN to fall back on, and, to turn it on, a reader authama can use.
func VerifyBiometric ¶
VerifyBiometric asks fprintd for a fingerprint match, for up to 30 seconds.
Types ¶
type Config ¶
type Config struct {
Version int `json:"version"`
Binding string `json:"binding"`
Store string `json:"store"`
Created time.Time `json:"created"`
PIN string `json:"pin,omitempty"`
PINSet time.Time `json:"pin_set,omitempty"`
Biometric bool `json:"biometric,omitempty"`
}
Config is owner.json in the config home. It holds no secret: the PIN is a hash, and the key is in the store it names.
type LockedError ¶
LockedError is a check refused because of earlier wrong PINs.
func (LockedError) Error ¶
func (e LockedError) Error() string
type State ¶
type State struct {
SetUp bool
Config *Config
Report seal.Report
// Problem is why the seal could not be checked at all - the key could not
// be read, or the seal file is missing - as opposed to a check that ran
// and found differences.
Problem string
}
State is what Verify found.