keyring

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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. Elsewhere the cache is a no-op and every acquisition prompts (macOS Keychain and Windows Credential Manager are planned as their own cache_GOOS.go implementations).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PromptNewPassphrase

func PromptNewPassphrase(label string) (string, error)

PromptNewPassphrase asks twice, used when creating the key header, where a typo would be unrecoverable.

func PromptPassphrase

func PromptPassphrase(label string) (string, error)

PromptPassphrase asks for an existing passphrase (non-empty).

func ReadSecret

func ReadSecret(label string) (string, error)

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 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, no-op elsewhere.

Jump to

Keyboard shortcuts

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