Documentation
¶
Index ¶
- Constants
- type Config
- type RewrapSystemKeysOptions
- type RewrapSystemKeysResult
- type Store
- func (s *Store) CreateKey(ctx context.Context, scope, scopeID string, version int, encryptedDEK []byte, ...) error
- func (s *Store) DestroyKeys(ctx context.Context, scope, scopeID string) error
- func (s *Store) GetActiveKey(ctx context.Context, scope, scopeID string) (*keystore.EncryptedKey, error)
- func (s *Store) GetKey(ctx context.Context, scope, scopeID string, version int) (*keystore.EncryptedKey, error)
- func (s *Store) RevokeKeys(ctx context.Context, scope, scopeID string) error
- func (s *Store) RewrapSystemKeys(ctx context.Context, keyring systemkey.Keyring, c cipher.Cipher, ...) (RewrapSystemKeysResult, error)
- type TxExtractor
Constants ¶
const ( // DefaultSchema is the default PostgreSQL schema for encryption keys. DefaultSchema = "infrastructure" // DefaultTable is the default PostgreSQL table name for encryption keys. DefaultTable = "encryption_keys" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config holds the schema and table names for the PostgreSQL keystore.
func ApplyDefaults ¶ added in v0.0.2
ApplyDefaults fills in the default schema and table names when omitted.
func DefaultConfig ¶ added in v0.0.2
func DefaultConfig() Config
DefaultConfig returns the default PostgreSQL keystore configuration.
type RewrapSystemKeysOptions ¶ added in v0.0.3
type RewrapSystemKeysOptions struct {
FromSystemKeyID string
ToSystemKeyID string
BatchSize int
DryRun bool
}
RewrapSystemKeysOptions configures Store.RewrapSystemKeys.
type RewrapSystemKeysResult ¶ added in v0.0.3
type RewrapSystemKeysResult struct {
MatchedRows int
RewrappedRows int
SkippedRows int
RemainingRows int
Batches int
}
RewrapSystemKeysResult summarizes a system-key rewrap run.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements keystore.KeyStore backed by PostgreSQL.
func NewStore ¶
NewStore creates a new PostgreSQL-backed keystore with the given config. Empty Schema defaults to "infrastructure"; empty Table defaults to "encryption_keys". Reads use the connection pool. Writes auto-commit via *pgxpool.Pool. Use keystore.WithTx(ctx, tx) to opt into transaction participation.
func NewStoreWithTxExtractor ¶
func NewStoreWithTxExtractor(cfg Config, db *pgxpool.Pool, extract TxExtractor) *Store
NewStoreWithTxExtractor creates a store with a custom tx extractor. Resolution order: custom extractor → library's keystore.WithTx → *pgxpool.Pool.
Use this for Unit of Work patterns where pgx.Tx lives under your own context key rather than the library's keystore.WithTx key.
func (*Store) CreateKey ¶
func (s *Store) CreateKey(ctx context.Context, scope, scopeID string, version int, encryptedDEK []byte, systemKeyID string) error
CreateKey inserts a new encrypted DEK into the keystore.
func (*Store) DestroyKeys ¶
DestroyKeys permanently deletes all keys for the given scope.
func (*Store) GetActiveKey ¶
func (s *Store) GetActiveKey(ctx context.Context, scope, scopeID string) (*keystore.EncryptedKey, error)
GetActiveKey returns the highest-version non-revoked key for the given scope.
func (*Store) GetKey ¶
func (s *Store) GetKey(ctx context.Context, scope, scopeID string, version int) (*keystore.EncryptedKey, error)
GetKey returns a specific key version for the given scope.
func (*Store) RevokeKeys ¶
RevokeKeys marks all active keys for the given scope as revoked, except the highest version (the current active key). Use DestroyKeys to permanently remove all keys including the active one.
func (*Store) RewrapSystemKeys ¶ added in v0.0.3
func (s *Store) RewrapSystemKeys(ctx context.Context, keyring systemkey.Keyring, c cipher.Cipher, opts RewrapSystemKeysOptions) (RewrapSystemKeysResult, error)
RewrapSystemKeys re-encrypts stored DEKs from one system key to another in short PostgreSQL-managed batch transactions.
This is an administrative operation for retiring old system keys. It updates only the stored encrypted DEK and system_key_id for matching rows; it does not create new DEK versions or touch application ciphertext.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package migrations exposes the embedded PostgreSQL keystore migration.
|
Package migrations exposes the embedded PostgreSQL keystore migration. |