vault

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package vault is Atlas's engine-internal encrypted secret store: worker credentials sealed at rest with AES-256-GCM under a master key that never leaves the operator's control (ADR-0069), on by default with a generated key file when no operator key is supplied (ADR-0070).

It exists as its own package so the boundary is enforced rather than merely intended: nothing here returns a plaintext secret except Vault.Get, nothing writes the master key anywhere but the key file, and a caller cannot reach past the API into a record. The rest of the server holds a *Vault and resolves secret *references*, so a credential never sits in a compiled process, an event, or a log line.

Index

Constants

View Source
const (
	KeyEnv     = "ATLAS_VAULT_KEY"
	KeyFileEnv = "ATLAS_VAULT_KEY_FILE"
)

Environment variables that configure the vault master key. The key is 32 bytes (AES-256), given as hex (64 chars) or base64. An operator key from either of these is preferred and, per ADR-0069, is NEVER written to disk by Atlas. When neither is set the vault is on by default and generates its own key file (ADR-0070).

Variables

This section is empty.

Functions

func ResolveKey

func ResolveKey(keyFile string) (key []byte, source string, err error)

ResolveKey sources the master key with operator precedence (ADR-0070): an operator key from the environment (ATLAS_VAULT_KEY / ATLAS_VAULT_KEY_FILE) wins and is never written to disk; absent one, the key is loaded from keyFile, or generated into it (mode 0600) so the vault is on by default without provisioning. source is "env", "file", or "generated" — the caller logs the generated case, which trades a weaker at-rest guarantee (key beside the ciphertext) for turnkey operation.

Types

type Meta

type Meta struct {
	Name      string `json:"name"`
	KeyID     string `json:"keyId"`
	CreatedAt int64  `json:"createdAt"`
	UpdatedAt int64  `json:"updatedAt"`
}

Meta is the value-free view of a secret returned by the API and List: it proves a secret exists and under which key, but never reveals the value.

type Vault

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

Vault is the engine-internal encrypted secret store (ADR-0069, closing the A3 option deferred by ADR-0041). It owns a sidecar directory — one JSON file per secret, hex-named, atomic write + dir fsync, the connectorStore pattern — and an AES-256-GCM cipher built from the master key. Like the other sidecar stores it is owned by the run-loop goroutine, so it needs no locking; and it writes only ciphertext, so no secret value ever reaches the WAL, an event, or a variable (I6).

func New

func New(dir string, key []byte) (*Vault, error)

New opens (creating if needed) the vault directory and builds the AES-256-GCM cipher from a 32-byte master key.

func (*Vault) Delete

func (v *Vault) Delete(name string) error

Delete removes a secret. A missing secret is not an error (idempotent).

func (*Vault) Get

func (v *Vault) Get(name string) (string, bool, error)

Get returns the decrypted value for a name, ok=false when no such secret exists. A record sealed under a different master key, or one that has been tampered with, is an error rather than a silent miss.

func (*Vault) List

func (v *Vault) List() ([]Meta, error)

List returns value-free metadata for every stored secret, oldest first. Non-record files are ignored.

func (*Vault) Set

func (v *Vault) Set(name, value string) (Meta, error)

Set seals value under name and stores it durably, returning the value-free metadata. The plaintext is sealed at once and never persisted; an overwrite keeps the original createdAt.

Jump to

Keyboard shortcuts

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