Documentation
¶
Overview ¶
Package secrets keeps account passwords out of the database: in the OS keychain (macOS login keychain, Windows Credential Manager, Secret Service), else a file only this user can read.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("secret not found")
ErrNotFound is returned when no secret is stored for an account.
Functions ¶
This section is empty.
Types ¶
type Fallback ¶
Fallback keeps secrets in the OS keychain and, where there is none (a Linux box without a Secret Service), in a file only this user can read.
type File ¶
type File struct {
Path string
// contains filtered or unexported fields
}
File is a JSON map of secrets in a 0600 file.
type Keychain ¶
type Keychain struct{}
Keychain is the OS keychain through go-keyring: Windows Credential Manager and Secret Service. Not used on macOS, where go-keyring runs `security` without naming the keychain file (ADR-039's dialog risk); MacKeychain is.
type MacKeychain ¶ added in v0.116.0
type MacKeychain struct {
Path string // the login keychain file
Run secret.Runner // nil runs /usr/bin/security; tests replace it
}
MacKeychain keeps each password as a generic password in the user's login keychain through internal/secret, which names the keychain file on every call, so no call can open a dialog. Items keep go-keyring's service and account, so a password saved by an earlier build is found.
func (MacKeychain) Delete ¶ added in v0.116.0
func (k MacKeychain) Delete(id int64) error
Delete removes a secret; a missing one is not an error.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is an in-process store for tests and previews; it never touches the OS.
type Store ¶
type Store interface {
Get(accountID int64) (string, error)
Set(accountID int64, secret string) error
Delete(accountID int64) error
}
Store keeps one secret per account.
func Default ¶ added in v0.116.0
Default is where Mail keeps passwords: on macOS the login keychain when its file exists, elsewhere the OS keychain, with the 0600 file behind either; only the file when CAPROCK_SECRET_STORE=file or there is no login keychain. Nothing runs until the first password is read or written: an unused Mail starts no process.