Documentation
¶
Overview ¶
Package vaultpg stores Vaults and Credentials in PostgreSQL.
Index ¶
- type Store
- func (s *Store) CountOwnedVaults(ctx context.Context, tenantID string, vaultIDs []string) (int, error)
- func (s *Store) CreateCredential(ctx context.Context, credential vaults.NewCredential) (vaults.Credential, error)
- func (s *Store) CreateVault(ctx context.Context, vault vaults.NewVault) (vaults.Vault, error)
- func (s *Store) DeleteCredential(ctx context.Context, key vaults.CredentialKey) (string, error)
- func (s *Store) DeleteVault(ctx context.Context, tenantID, vaultID string) (string, error)
- func (s *Store) FindMCPCredentials(ctx context.Context, query vaults.MCPCredentialQuery) ([]vaults.MCPCredentialMatch, error)
- func (s *Store) GetCredential(ctx context.Context, tenantID, vaultID, credentialID string) (vaults.Credential, error)
- func (s *Store) GetVault(ctx context.Context, tenantID, vaultID string) (vaults.Vault, error)
- func (s *Store) ListCredentials(ctx context.Context, tenantID, vaultID string, query vaults.PageQuery) (vaults.CredentialPage, error)
- func (s *Store) ListVaults(ctx context.Context, tenantID string, query vaults.PageQuery) (vaults.VaultPage, error)
- func (s *Store) ReplaceStaticToken(ctx context.Context, replacement vaults.StaticTokenReplacement) (vaults.Credential, error)
- func (s *Store) StaticToken(ctx context.Context, query vaults.StaticTokenQuery) (string, error)
- func (s *Store) WithOAuthCredential(ctx context.Context, key vaults.CredentialKey, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store runs on pooled connections and seals and opens the Credential secrets it stores. Credential operations never need the execution lease: an OAuth refresh holds its Credential's row lock for up to the refresh bound and must not hold up execution-owner work.
func New ¶
func New(pool *pgunit.Pool, cipher *credentialcrypto.Cipher) *Store
New returns a Store that seals and opens secrets with cipher.
func (*Store) CountOwnedVaults ¶
func (*Store) CreateCredential ¶
func (s *Store) CreateCredential(ctx context.Context, credential vaults.NewCredential) (vaults.Credential, error)
CreateCredential admits the owning Vault in the insert itself, so a missing, foreign or malformed Vault stores nothing and is ErrNotFound, as is a Vault deleted while the insert waits on it. A malformed new Credential ID is ErrInvalidInput.
func (*Store) CreateVault ¶
func (*Store) DeleteCredential ¶
DeleteCredential removes the sealed secret without reading it.
func (*Store) DeleteVault ¶
DeleteVault relies on the owning foreign key to remove every stored Credential.
func (*Store) FindMCPCredentials ¶
func (s *Store) FindMCPCredentials(ctx context.Context, query vaults.MCPCredentialQuery) ([]vaults.MCPCredentialMatch, error)
func (*Store) GetCredential ¶
func (*Store) ListCredentials ¶
func (s *Store) ListCredentials(ctx context.Context, tenantID, vaultID string, query vaults.PageQuery) (vaults.CredentialPage, error)
ListCredentials reads the parent Vault, the cursor and the page from one snapshot. A parent ID that cannot name a Vault is ErrNotFound.
func (*Store) ListVaults ¶
func (s *Store) ListVaults(ctx context.Context, tenantID string, query vaults.PageQuery) (vaults.VaultPage, error)
ListVaults reads the cursor and the page from one snapshot.
func (*Store) ReplaceStaticToken ¶
func (s *Store) ReplaceStaticToken(ctx context.Context, replacement vaults.StaticTokenReplacement) (vaults.Credential, error)
ReplaceStaticToken matches the destination the token is sealed to, so a concurrent change of scope stores nothing.
func (*Store) StaticToken ¶
StaticToken is the only read of a static token. Resource reads never select ciphertext.