Documentation
¶
Overview ¶
Package storage provides the storage abstraction layer for encrypted vault records.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCASFailed = errors.New("CAS version mismatch")
ErrCASFailed is returned when a compare-and-swap version check fails.
View Source
var ErrNotFound = errors.New("record not found")
ErrNotFound is returned when a record does not exist.
View Source
var ErrVaultNotFound = errors.New("vault not found")
ErrVaultNotFound is returned when a vault does not exist in storage.
Functions ¶
Types ¶
type BatchTx ¶
type BatchTx interface {
Put(recordType string, recordID string, envelope *Envelope) error
PutCAS(recordType string, recordID string, expectedVersion uint64, envelope *Envelope) error
Delete(recordType string, recordID string) error
}
BatchTx provides Put, PutCAS, and Delete within an atomic transaction. The vaultID is scoped to the batch, so methods don't require it.
type Envelope ¶
type Envelope struct {
Ver int `json:"ver"`
Scheme string `json:"scheme"`
Nonce []byte `json:"nonce"`
Ciphertext []byte `json:"ciphertext"`
Version uint64 `json:"version,omitempty"`
}
Envelope is a sealed record containing AES-256-GCM encrypted data.
type Repository ¶
type Repository interface {
Put(vaultID string, recordType string, recordID string, envelope *Envelope) error
Get(vaultID string, recordType string, recordID string) (*Envelope, error)
List(vaultID string, recordType string) ([]string, error)
ListVaults() ([]string, error)
Delete(vaultID string, recordType string, recordID string) error
DeleteVault(vaultID string) error
PutCAS(vaultID string, recordType string, recordID string, expectedVersion uint64, envelope *Envelope) error
Batch(vaultID string, fn func(tx BatchTx) error) error
}
Repository defines the interface for encrypted record storage.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bbolt provides a BBolt-backed storage repository.
|
Package bbolt provides a BBolt-backed storage repository. |
|
Package memory provides a thread-safe in-memory implementation of storage.Repository.
|
Package memory provides a thread-safe in-memory implementation of storage.Repository. |
|
Package postgres implements storage.Repository backed by PostgreSQL.
|
Package postgres implements storage.Repository backed by PostgreSQL. |
Click to show internal directories.
Click to hide internal directories.