owner

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const (
	StoreFile     = "file"
	StoreKeychain = "keychain"
	StoreSecret   = "secret-service"
	StoreDPAPI    = "dpapi"
)

Store names.

View Source
const ConfigVersion = 1

ConfigVersion is owner.json's format.

View Source
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

View Source
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.

View Source
var ErrNoKey = errors.New("no sealing key is stored")

ErrNoKey is a store that holds no key for this home.

Functions

func BiometricAvailable

func BiometricAvailable() (bool, string)

BiometricAvailable reports whether fprintd can verify a fingerprint for this user: the tool is installed and a finger is enrolled.

func CheckPIN

func CheckPIN(p paths.Paths, candidate string, now time.Time) error

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 ConfigPath

func ConfigPath(p paths.Paths) string

ConfigPath is owner.json.

func CurrentBinding

func CurrentBinding() (seal.Binding, error)

CurrentBinding is the account and machine this process runs as.

func Forget

func Forget(p paths.Paths) error

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

func MachineID() (string, error)

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 Platform

func Platform() string

Platform names the OS family, for messages.

func Recoverable

func Recoverable(p paths.Paths) error

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 RemovePIN

func RemovePIN(p paths.Paths, current string, now time.Time) error

RemovePIN turns the PIN off; current must match it.

func Reseal

func Reseal(p paths.Paths, now time.Time) error

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

func ResetPIN(p paths.Paths, next string, now time.Time) error

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 SealPath

func SealPath(p paths.Paths) string

SealPath is the seal record, in the state home.

func SealedFiles

func SealedFiles(p paths.Paths) map[string]string

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

func SetBiometric(p paths.Paths, on bool, now time.Time) error

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 SetPIN

func SetPIN(p paths.Paths, current, next string, now time.Time) error

SetPIN sets the PIN, or changes it: with one set, current must match it.

func VerifyBiometric

func VerifyBiometric(ctx context.Context) error

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.

func Init

func Init(p paths.Paths, now time.Time) (*Config, error)

Init binds the home: a new key in the store, owner.json, and a first seal.

func Load

func Load(p paths.Paths) (*Config, error)

Load reads owner.json. A home with none returns (nil, nil).

func (*Config) HasPIN

func (c *Config) HasPIN() bool

HasPIN reports whether a PIN is set.

type LockedError

type LockedError struct{ Until time.Time }

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.

func Verify

func Verify(p paths.Paths) State

Verify checks the files against the seal. It never changes anything.

func (State) Clean

func (s State) Clean() bool

Clean reports a home with no owner, or one whose seal checks out.

func (State) Describe

func (s State) Describe() string

Describe is a one-paragraph account of a State that is not clean.

type Store

type Store interface {
	Name() string
	Load() ([]byte, error)
	Save(key []byte) error
	Remove() error
}

Store keeps the sealing key for the user.

func StoreFor

func StoreFor(p paths.Paths) Store

StoreFor picks the store for a new key: the OS's own where it has one this process can reach, else the file. A --dev-root sandbox always uses the file inside the sandbox, so a test never writes to the real keychain.

Jump to

Keyboard shortcuts

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