Documentation
¶
Overview ¶
Package secrets keeps device tokens out of the database and the vault (ADR-0016, docs/specs/sync-protocol.md): the Secret Service over D-Bus, and a plain File for development and CI. Ported from frostmail's internal/secrets (frostmail ADR-0011).
Index ¶
Constants ¶
const ProbeKey = "probe"
ProbeKey is the key a pairing writes and deletes first: a store that cannot keep it cannot keep a device token either, and the store's prompt then comes before the hub knows the device.
Variables ¶
var ErrDismissed = errors.New("secrets: the Secret Service's prompt was dismissed")
ErrDismissed means the user dismissed one of the service's prompts: to unlock a collection, or to make the default one.
var ErrNoKeyring = errors.New("secrets: the Secret Service cannot make a default collection: " +
"set FROSTNOTES_SECRETS=file to keep tokens in a file")
ErrNoKeyring means the Secret Service has no default collection and cannot make one, so no token can be kept in it.
var ErrNotFound = errors.New("secrets: not found")
ErrNotFound means no secret is stored under the key.
ErrUnavailable means no Secret Service answered on the bus.
Functions ¶
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a Store kept in one JSON object ({"key": "value", ...}) in a file with mode 0600: plain text on disk, guarded only by file permissions, for development, CI and machines without a Secret Service.
func NewFile ¶
NewFile returns a File store at path. The file is created on first Set; its directory must exist.
func (*File) Delete ¶
Delete removes key, rewriting the file atomically like Set. A missing key or a missing file is not an error.
func (*File) Get ¶
Get returns the secret stored under key, or ErrNotFound. A missing file holds no secrets. A file whose mode allows group or other access is refused with an error naming the file and its mode.
type SecretService ¶
type SecretService struct {
// contains filtered or unexported fields
}
SecretService is a Store in the desktop's Secret Service.
func OpenSecretService ¶
OpenSecretService opens a plain session with the Secret Service on conn, or returns an error wrapping ErrUnavailable.
func (*SecretService) Delete ¶
func (s *SecretService) Delete(ctx context.Context, key string) error
Delete removes key; a missing key is not an error.
type Store ¶
type Store interface {
// Get returns the secret, or ErrNotFound.
Get(ctx context.Context, key string) (string, error)
// Set stores the secret, replacing any previous value.
Set(ctx context.Context, key, value string) error
// Delete removes the secret; a missing key is not an error.
Delete(ctx context.Context, key string) error
}
Store keeps string secrets by key.