sqlstore

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sqlstore provides a SQL table-backed vault implementation.

Index

Constants

View Source
const (

	// DialectMySQL uses MySQL-compatible SQL, including DoltDB.
	DialectMySQL = "mysql"
	// DialectPostgres uses PostgreSQL-compatible SQL.
	DialectPostgres = "postgres"
	// DialectSQLite uses SQLite-compatible SQL.
	DialectSQLite = "sqlite"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DB is the open SQL database handle. The caller owns its lifetime.
	DB *sql.DB

	// Table is the table that stores encrypted secrets. Defaults to
	// "omnivault_secrets".
	Table string

	// Dialect controls placeholder and upsert syntax. Supported values are
	// "mysql", "postgres", and "sqlite". Empty defaults to "mysql".
	Dialect string

	// EncryptionKey is the AES key used to encrypt secret payloads. It must be
	// 16, 24, or 32 bytes. Store this key outside the database, for example in
	// env, keyring, or a cloud secret manager.
	EncryptionKey []byte

	// KeyID is optional metadata that identifies which key encrypted a row.
	KeyID string

	// AutoMigrate creates the table if it does not already exist.
	AutoMigrate bool

	// ReadOnly prevents writes and deletes.
	ReadOnly bool
}

Config configures the SQL-backed vault provider.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements vault.Vault with encrypted rows in a SQL table.

func New

func New(config Config) (*Provider, error)

New creates a SQL-backed vault provider.

func (*Provider) Capabilities

func (p *Provider) Capabilities() vault.Capabilities

Capabilities returns provider capabilities.

func (*Provider) Close

func (p *Provider) Close() error

Close does not close the caller-owned database handle.

func (*Provider) Delete

func (p *Provider) Delete(ctx context.Context, path string) error

Delete removes a secret.

func (*Provider) Exists

func (p *Provider) Exists(ctx context.Context, path string) (bool, error)

Exists checks whether a secret exists.

func (*Provider) Get

func (p *Provider) Get(ctx context.Context, path string) (*vault.Secret, error)

Get retrieves and decrypts a secret.

func (*Provider) List

func (p *Provider) List(ctx context.Context, prefix string) ([]string, error)

List returns secret paths with the given prefix.

func (*Provider) Migrate

func (p *Provider) Migrate(ctx context.Context) error

Migrate creates the provider table if it does not exist.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

func (*Provider) Set

func (p *Provider) Set(ctx context.Context, path string, secret *vault.Secret) error

Set encrypts and stores a secret.

Jump to

Keyboard shortcuts

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