Documentation
¶
Overview ¶
Package keyring handles credential acquisition: hidden terminal prompts plus a platform-specific session cache for the unwrapped master key. On Linux the cache is the kernel keyring: the key lives in kernel memory, expires on TTL, and never touches disk, the same trust model as an ssh-agent. On macOS it is the Keychain and on Windows DPAPI, each holding the key as ciphertext under the user's login credentials with a lazy TTL (see the cache_GOOS.go implementations). On any other platform the cache is a no-op and every acquisition prompts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratePassphrase ¶ added in v0.13.0
GeneratePassphrase returns a random diceware-style passphrase: eight words drawn uniformly from the embedded wordlist, hyphen-joined. Used for the credentials notenv mints itself (the creation passphrase and the temporary onboarding credential), which must be high-entropy without asking a human to invent it (humans pick weak ones) and easy to relay over a chat message.
func PromptNewPassphrase ¶
PromptNewPassphrase asks twice, used when creating the key header, where a typo would be unrecoverable.
func PromptPassphrase ¶
PromptPassphrase asks for an existing passphrase (non-empty).
func ReadSecret ¶
ReadSecret prompts on the controlling terminal with echo disabled. It prefers the console device (/dev/tty; CONIN$ on Windows) so prompts work even when stdin is a pipe (e.g. `notenv secret set --stdin`).
Types ¶
type Cache ¶
type Cache interface {
// Get returns the cached master key for a scope, if present.
Get(scope string) (string, bool)
// Store caches the master key. A non-positive ttl is the caller's
// signal not to call Store at all; implementations may also treat it
// as "do not cache".
Store(scope, masterKey string, ttl time.Duration) error
// Drop invalidates a cached master key (e.g. after it failed to
// decrypt because the vault was re-keyed under a new one).
Drop(scope string)
}
Cache is a session-scoped cache for the unwrapped master key (its identity string: never the passphrase, which unlocks every future rewrap and is strictly more valuable). Keyed by an opaque scope string (notenv uses a length-prefixed remote+base, one entry per storage base, see config.CacheScope). Implementations must never persist the key to disk.
func DefaultCache ¶
func DefaultCache() Cache
DefaultCache returns this platform's cache: kernel keyring on Linux, Keychain on macOS, DPAPI on Windows, no-op elsewhere.