vaultpg

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package vaultpg stores Vaults and Credentials in PostgreSQL.

Index

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. Without a credential key (cipher nil), operations that seal or open a secret fail with credentialcrypto.ErrUnavailable; Vaults, Credential metadata, selection and deletion keep working.

func (*Store) CountOwnedVaults

func (s *Store) CountOwnedVaults(ctx context.Context, tenantID string, vaultIDs []string) (int, error)

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 (s *Store) CreateVault(ctx context.Context, vault vaults.NewVault) (vaults.Vault, error)

func (*Store) DeleteCredential

func (s *Store) DeleteCredential(ctx context.Context, key vaults.CredentialKey) (string, error)

DeleteCredential removes the sealed secret without reading it.

func (*Store) DeleteVault

func (s *Store) DeleteVault(ctx context.Context, tenantID, vaultID string) (string, error)

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 (s *Store) GetCredential(ctx context.Context, tenantID, vaultID, credentialID string) (vaults.Credential, error)

func (*Store) GetVault

func (s *Store) GetVault(ctx context.Context, tenantID, vaultID string) (vaults.Vault, error)

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

func (s *Store) StaticToken(ctx context.Context, query vaults.StaticTokenQuery) (string, error)

StaticToken is the only read of a static token. Resource reads never select ciphertext.

func (*Store) WithOAuthCredential

func (s *Store) WithOAuthCredential(ctx context.Context, key vaults.CredentialKey, apply func(vaults.OAuthTx) error) error

WithOAuthCredential holds the Credential's row lock, once loaded, until apply returns: through an external refresh too.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL