Documentation
¶
Index ¶
- func NullProvider() credential.CredentialProvider
- type Manager
- func (self *Manager) CreateCredential(ctx context.Context, req schema.CredentialCreate) (_ *schema.Credential, err error)
- func (self *Manager) DeleteCredential(ctx context.Context, key schema.CredentialKey) (_ *schema.Credential, err error)
- func (self *Manager) DescribeCredential(ctx context.Context, key schema.CredentialKey, description string) (_ *schema.Credential, err error)
- func (self *Manager) GetCredential(ctx context.Context, key schema.CredentialKey, passphrase string) (_ json.RawMessage, err error)
- func (self *Manager) GetCredentialMeta(ctx context.Context, key schema.CredentialKey) (_ *schema.Credential, err error)
- func (self *Manager) GetCredentialProvider() credential.CredentialProvider
- func (self *Manager) GetCredentialWithoutPassphrase(ctx context.Context, key schema.CredentialKey) (_ json.RawMessage, err error)
- func (self *Manager) ListCredentials(ctx context.Context, req schema.CredentialListRequest) (_ *schema.CredentialList, err error)
- func (self *Manager) RotateCredential(ctx context.Context, key schema.CredentialKey) (_ *schema.Credential, err error)
- type Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NullProvider ¶
func NullProvider() credential.CredentialProvider
NullProvider returns a provider for when there are no credentials, such as when no passphrase is configured. A value without placeholders is returned unchanged, and a value with placeholders is an error.
Types ¶
type Manager ¶
func (*Manager) CreateCredential ¶
func (self *Manager) CreateCredential(ctx context.Context, req schema.CredentialCreate) (_ *schema.Credential, err error)
CreateCredential encrypts the credentials with the latest passphrase and stores them, replacing any credentials with the same key. It returns the public credential shape, excluding the passphrase version and encrypted payload.
func (*Manager) DeleteCredential ¶
func (self *Manager) DeleteCredential(ctx context.Context, key schema.CredentialKey) (_ *schema.Credential, err error)
DeleteCredential deletes the credential for the key, and returns the key and the time it was last stored
func (*Manager) DescribeCredential ¶
func (self *Manager) DescribeCredential(ctx context.Context, key schema.CredentialKey, description string) (_ *schema.Credential, err error)
DescribeCredential sets the description of a credential, or removes it, when it's empty, without changing when it was updated, and returns the credential. Returns pg.ErrNotFound, as auth.ErrNotFound, when there's no credential for the key.
func (*Manager) GetCredential ¶
func (self *Manager) GetCredential(ctx context.Context, key schema.CredentialKey, passphrase string) (_ json.RawMessage, err error)
GetCredential retrieves a credential by key, and decrypts it if the passphrase is the one it was encrypted with. Returns the credential as JSON, or ErrForbidden if the passphrase is not the credential's passphrase.
func (*Manager) GetCredentialMeta ¶
func (self *Manager) GetCredentialMeta(ctx context.Context, key schema.CredentialKey) (_ *schema.Credential, err error)
GetCredentialMeta returns the key of a credential, and the time it was stored, without reading or decrypting the credential, so it does not need a passphrase. Returns auth.ErrNotFound, which also matches pg.ErrNotFound, if there is no credential for the key.
func (*Manager) GetCredentialProvider ¶
func (self *Manager) GetCredentialProvider() credential.CredentialProvider
GetCredentialProvider returns a provider which substitutes credentials for placeholders. Credentials are decrypted without a passphrase, so the provider is for internal server-side use only, and must not be exposed via any public API or HTTP handler. With WithEnv, a credential which isn't stored is read from the environment, and without a passphrase, every credential is.
func (*Manager) GetCredentialWithoutPassphrase ¶
func (self *Manager) GetCredentialWithoutPassphrase(ctx context.Context, key schema.CredentialKey) (_ json.RawMessage, err error)
GetCredentialWithoutPassphrase retrieves and decrypts a credential using the stored passphrase version. It is intended for internal server-side use only and must not be exposed via any public API or HTTP handler.
func (*Manager) ListCredentials ¶
func (self *Manager) ListCredentials(ctx context.Context, req schema.CredentialListRequest) (_ *schema.CredentialList, err error)
ListCredentials returns a page of credentials in key order, without their encrypted payloads. When Rotate is set, only the credentials which need rotating to the latest passphrase version are returned, or when it is false, only those which don't.
func (*Manager) RotateCredential ¶
func (self *Manager) RotateCredential(ctx context.Context, key schema.CredentialKey) (_ *schema.Credential, err error)
RotateCredential re-encrypts a credential with the latest passphrase version, without changing its value. Returns ErrNotModified if the credential already uses the latest version, or ErrConflict if the credential was changed or deleted while it was being rotated.
type Opt ¶
type Opt func(*opt) error
Opt is a functional option for credential manager configuration.
func WithChannel ¶
WithChannel notifies the channel of each change of a credential, by its key, without its value, with a trigger, which go-pg's pgbroadcaster publishes, such as to a web UI, whatever makes the change. Without it, there's no trigger.
func WithEnv ¶
func WithEnv() Opt
WithEnv reads a credential from the environment when it isn't stored in the database, so $KEY is expanded from the environment variable KEY. The environment is read-only, so credentials are still stored in the database.
func WithPassphrase ¶
WithPassphrase registers an in-memory storage passphrase for a certificate passphrase version. Versions are uint64 and passphrases must be non-empty.
func WithSchema ¶
WithSchema sets the database schema used for storing credentials.
func WithTracer ¶
WithTracer sets the tracer used for tracing operations.