Documentation
¶
Overview ¶
Package secrets provides an optional, opt-in abstraction over the OS keyring for storing user credentials. All operations degrade gracefully when the keyring backend is unavailable (headless CI, no D-Bus, locked keychain) so the CLI never aborts or hangs because of it.
Index ¶
Constants ¶
View Source
const ( FieldAPIKey = "apikey" FieldPassword = "password" )
Field names for the two secrets that may live in the keyring.
View Source
const Service = "redmine-cli"
Service is the keyring service name used for all redmine-cli secrets.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Store ¶
type Store interface {
// Get returns the stored secret. ok is false with a nil error when nothing
// is stored; err is only non-nil for a real backend failure.
Get(profile, field string) (secret string, ok bool, err error)
Set(profile, field, secret string) error
Delete(profile, field string) error
// Available reports, best-effort, whether the keyring backend is usable on
// this machine.
Available() bool
}
Store abstracts credential storage so the keyring backend can be swapped for an in-memory fake in tests.
var Default Store = keyringStore{}
Default is the process-wide Store. Tests may reassign it to substitute a fake, or call keyring.MockInit to redirect the real backend in memory.
Click to show internal directories.
Click to hide internal directories.