secrets

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package secrets is the platform's encryption seam for vault credential material (docs/plan/12_vaults-credentials.md, D1): reversible encryption of small secret values behind the one interface every backend must satisfy (CLAUDE.md: backend variability lives behind an interface with one shared contract suite — internal/secrets/secretstest). Postgres stays the canonical store — callers persist the ciphertext and key id next to the resource row; this package only transforms bytes. The production backend is OpenBao's transit engine (internal/secrets/openbao); internal/secrets/gcpkms is the Cloud KMS backend a GCP deployment uses instead, and internal/secrets/local is the AES-256-GCM fallback for tests and minimal deployments.

This package holds the interface and the errors backends wrap, so it imports none of them: selecting one from the environment is internal/secrets/backend, a sibling for the same structural reason internal/sandbox/backend is one.

Index

Constants

This section is empty.

Variables

View Source
var ErrPlaintextTooLarge = errors.New("secrets: plaintext is too large for this cipher")

ErrPlaintextTooLarge reports material a cipher cannot seal because its encryption service bounds the input. Not every backend has such a bound — local and openbao seal any size — so this is a contract for the ones that do: they wrap it, and a caller turning a Cipher failure into a response classifies it as the caller's error rather than the server's. Without that, the refusal reaches the client as a generic 500 and the useful message lives only in the server's log (docs/plan/20_gcp-deployment.md, Decision 3).

Functions

This section is empty.

Types

type Cipher

type Cipher interface {
	// Encrypt seals plaintext (non-empty) and names the key that sealed it.
	// The ciphertext is opaque to callers; store it with the keyID and hand
	// both back to Decrypt.
	Encrypt(ctx context.Context, plaintext []byte) (ciphertext []byte, keyID string, err error)

	// Decrypt reverses Encrypt. Tampered, truncated, or foreign ciphertext —
	// or a keyID this cipher does not hold — is an error.
	Decrypt(ctx context.Context, ciphertext []byte, keyID string) ([]byte, error)
}

Cipher encrypts and decrypts vault secret material. Implementations must bind each ciphertext to the key that produced it: Decrypt with a keyID the ciphertext was not encrypted under is an error, never a silent success.

Directories

Path Synopsis
Package backend selects a secrets cipher by name, so every binary that encrypts vault credential material constructs it from the same config point instead of each mapping the environment its own way.
Package backend selects a secrets cipher by name, so every binary that encrypts vault credential material constructs it from the same config point instead of each mapping the environment its own way.
Package gcpkms is a secrets.Cipher backed by Cloud KMS's raw Encrypt and Decrypt: the key material never leaves the service, and the platform stores only ciphertext (docs/plan/20_gcp-deployment.md, Decision 3).
Package gcpkms is a secrets.Cipher backed by Cloud KMS's raw Encrypt and Decrypt: the key material never leaves the service, and the platform stores only ciphertext (docs/plan/20_gcp-deployment.md, Decision 3).
gcpkmstest
Package gcpkmstest is test support for the gcpkms cipher: an in-process fake Cloud KMS gRPC server, so the shared secrets contract runs hermetically and `make test` never touches GCP or spends money, plus the opt-in gate for the live tier that calls the real service.
Package gcpkmstest is test support for the gcpkms cipher: an in-process fake Cloud KMS gRPC server, so the shared secrets contract runs hermetically and `make test` never touches GCP or spends money, plus the opt-in gate for the live tier that calls the real service.
Package local is the AES-256-GCM secrets.Cipher for tests and minimal deployments: one 32-byte master key from configuration, no external service.
Package local is the AES-256-GCM secrets.Cipher for tests and minimal deployments: one 32-byte master key from configuration, no external service.
Package openbao is the production secrets.Cipher: encryption as a service through an OpenBao (or any Vault-compatible) transit engine, spoken over its plain HTTP API — deliberately not the official client library, whose dependency tree buys nothing for the two calls this needs (docs/plan/12, D1).
Package openbao is the production secrets.Cipher: encryption as a service through an OpenBao (or any Vault-compatible) transit engine, spoken over its plain HTTP API — deliberately not the official client library, whose dependency tree buys nothing for the two calls this needs (docs/plan/12, D1).
Package secretstest is test support for the secrets.Cipher seam: the shared contract suite (contract.go) plus a Dockerized OpenBao dev-mode container started once per test binary, with the transit engine mounted and per-test key names handed out.
Package secretstest is test support for the secrets.Cipher seam: the shared contract suite (contract.go) plus a Dockerized OpenBao dev-mode container started once per test binary, with the transit engine mounted and per-test key names handed out.

Jump to

Keyboard shortcuts

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