Documentation
¶
Overview ¶
Package keyring is one credential store for a Go desktop app: the OS keyring, with a sealed-file fallback inside a Flatpak.
Index ¶
- Constants
- Variables
- type Options
- type Store
- func (s *Store) Delete(name string) error
- func (s *Store) DeleteIn(service, name string) error
- func (s *Store) Get(name string) (string, error)
- func (s *Store) GetIn(service, name string) (string, error)
- func (s *Store) Plaintext() (bool, error)
- func (s *Store) Set(name, value string) error
- func (s *Store) SetIn(service, name, value string) error
Constants ¶
const ZalandoVersion = "v0.2.8"
ZalandoVersion is the zalando/go-keyring version this release's live tests ran against.
Variables ¶
var ( // ErrNotFound is zalando's ErrNotFound, the same value, so errors.Is holds for a caller that mocks the // backend with zalando's MockInit. ErrNotFound = zkeyring.ErrNotFound // ErrTooBig is zalando's ErrSetDataTooBig, the same value: Windows refuses a credential over 2,560 bytes. ErrTooBig = zkeyring.ErrSetDataTooBig // ErrPending means a read is still waiting on an unlock prompt. It is not a failure: the read keeps running // and Options.OnUnlocked fires when it completes. Plaintext also returns it when the store is busy. ErrPending = errors.New("keyring: waiting for the keyring to be unlocked") // ErrLocked wraps the backend error when an unlock prompt was dismissed or failed. Nothing is cached: the // next call prompts again. ErrLocked = errors.New("keyring: the keyring stayed locked") // ErrReservedName means an item of the store's own service is named "<shared service>.<name>", which the // Flatpak files keep for that shared service's item. ErrReservedName = errors.New("keyring: the name collides with a shared service's item") // ErrNoProvider wraps the D-Bus error raised when nothing answers as the Secret Service. ErrNoProvider = errors.New("keyring: no Secret Service provider is running") )
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Service string // keyring service for Get, Set and Delete. Required
SealInfo string // HKDF info deriving the sealed file's key from the portal secret. Required
Folder string // the Flatpak store's folder name under the data home. Required, one path element
// a plain file moving to the host keyring puts those back under (service, name).
SharedServices []string
// ReadTimeout bounds how long Get waits before returning ErrPending. Zero means 3s.
ReadTimeout time.Duration
// PortalTimeout bounds the Secret portal call, which may sit behind a dialog. Zero means no bound.
PortalTimeout time.Duration
// OnUnlocked runs after a read that outlived ReadTimeout completes, or was overtaken by a Set or Delete, so
// the app can retry what it deferred.
OnUnlocked func()
}
Options configures a Store. Service, SealInfo and Folder have no defaults: a derived one would let two programs share a store without either choosing it.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is one credential store. Use one Store per Folder per process: the Flatpak store's lock is per Store.
func (*Store) Delete ¶
Delete removes the secret under name; one that is already gone is not an error. It is not bounded.
func (*Store) GetIn ¶
GetIn returns the secret another program shares under its own service and name. Outside a Flatpak, and in host-keyring mode, that program can read it too.
func (*Store) Plaintext ¶
Plaintext reports whether secrets are in the unencrypted fallback file: inside a Flatpak, with neither the secret portal nor a host Secret Service. A store busy with a prompt returns (false, ErrPending) instead of waiting; a store that cannot be resolved returns (false, err).