Documentation
¶
Index ¶
- type Manager
- func (self *Manager) Decrypt(ctx context.Context, key, passphrase string) (_ json.RawMessage, err error)
- func (self *Manager) Delete(ctx context.Context, key string) (err error)
- func (self *Manager) Describe(ctx context.Context, key, description string) (err error)
- func (self *Manager) Expand(ctx context.Context, value string) (_ string, err error)
- func (self *Manager) Get(ctx context.Context, key string) (_ json.RawMessage, err error)
- func (self *Manager) List(ctx context.Context) (_ []credential.Credential, err error)
- func (self *Manager) Path() string
- func (self *Manager) Rotate(ctx context.Context, key string) (err error)
- func (self *Manager) Set(ctx context.Context, key string, value json.RawMessage) (err error)
- type Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
Manager stores credentials in files in a directory, one for each key, encrypted with a passphrase. Each file is a record: the passphrase version, the credential's description, which isn't encrypted, and the encrypted credential.
func New ¶
New returns a manager for credentials in the directory at the path. The directory is created when it doesn't exist, its permissions are set so that only its owner can access it, and it must be writable.
func (*Manager) Decrypt ¶
func (self *Manager) Decrypt(ctx context.Context, key, passphrase string) (_ json.RawMessage, err error)
Decrypt returns the credential for the key, as JSON, when the passphrase is the one it was encrypted with, compared in constant time, or ErrForbidden when it isn't
func (*Manager) Delete ¶
Delete removes the file for the key, and returns ErrNotFound when there isn't one
func (*Manager) Describe ¶
Describe sets the description of the key's credential, in its file, which isn't encrypted, as a description isn't secret, so it needs no passphrase, or removes it, when it's empty, and returns ErrNotFound when there's no credential
func (*Manager) Expand ¶
Expand replaces each $KEY or ${KEY} placeholder in the value with the credential for the key, which must be a string, or with the environment variable, with WithEnv, when there is no file for it. Keys containing "-" must use the ${KEY} form. Returns an error, rather than a partly expanded value, if a placeholder is not a valid key, or its credential does not exist or is not a string.
func (*Manager) Get ¶
Get returns the credential for the key, as JSON, or the environment variable's value, with WithEnv, when there is no file for it. Returns an error if the key isn't valid, or the credential doesn't exist.
func (*Manager) List ¶
func (self *Manager) List(ctx context.Context) (_ []credential.Credential, err error)
List returns the stored credentials, in key order, with their descriptions, without reading or decrypting their values. Files whose names aren't keys, such as temporary files, aren't listed.
func (*Manager) Rotate ¶
Rotate re-encrypts the file for the key with the latest passphrase, keeping its description, and returns ErrNotModified when it already uses it, or ErrNotFound when there isn't one
type Opt ¶
type Opt func(*opt) error
Opt is a functional option for the file credential manager
func WithEnv ¶
func WithEnv() Opt
WithEnv reads a credential from the environment when it isn't stored in a file, so $KEY is expanded from the environment variable KEY. The environment is read-only, so credentials are still stored in files.
func WithPassphrase ¶
WithPassphrase registers a passphrase for a passphrase version. Credentials are encrypted with the latest version, and decrypted with the version they were encrypted with. Versions are uint64 and passphrases must be non-empty.
func WithTracer ¶
WithTracer sets the tracer used for tracing operations