Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoNonInteractiveSource = errors.New("no non-interactive passphrase source available")
ErrNoNonInteractiveSource is returned by AcquireNonInteractive when neither the keyring nor a keyfile can provide a passphrase. Callers that see this error should gracefully degrade (show zero counts, skip DB sections, etc.) instead of propagating the error to the user.
Functions ¶
func ReadKeyfile ¶
ReadKeyfile reads the passphrase from a keyfile, validating file permissions. Returns the passphrase with trailing whitespace trimmed.
func ReadStdinPipe ¶
ReadStdinPipe reads a single line from non-terminal stdin. Returns an error if the line is empty after trimming.
func ShredKeyfile ¶
ShredKeyfile overwrites the keyfile content with zeros, syncs to disk, and removes it. Returns nil if the file does not exist (idempotent).
func ValidatePermissions ¶
ValidatePermissions checks that the file has exactly 0600 permissions.
func WriteKeyfile ¶
WriteKeyfile creates a keyfile with 0600 permissions. Parent directories are created with 0700 permissions if needed.
Types ¶
type Options ¶
type Options struct {
KeyfilePath string // default: ~/.lango/keyfile
AllowCreation bool // if true, prompt for confirmation on new passphrase
KeyringProvider keyring.Provider // if non-nil, try secure keyring first (biometric/TPM)
}
Options configures passphrase acquisition behavior.
type Source ¶
type Source int
Source represents how the passphrase was obtained.
func Acquire ¶
Acquire obtains a passphrase from the highest-priority available source. Priority: keyring -> keyfile -> interactive terminal -> stdin pipe -> error
func AcquireNonInteractive ¶ added in v0.7.0
AcquireNonInteractive obtains a passphrase WITHOUT triggering any interactive terminal prompt or stdin pipe read. It is used by commands that must work in non-interactive environments (e.g. `lango security status` default path) while still being able to read stored state when a passphrase is available.
Priority:
- Secure keyring (Touch ID / TPM) — OS-level biometric prompts are permitted because they are not CLI interactive prompts. TPM reads are silent.
- Keyfile at opts.KeyfilePath (or the default ~/.lango/keyfile).
If neither source yields a passphrase, the function returns ErrNoNonInteractiveSource. It SHALL NEVER call term.ReadPassword or read from os.Stdin pipe. It SHALL NEVER block on user input beyond whatever the keyring provider itself does (e.g., a Touch ID prompt).