Documentation
¶
Overview ¶
Package secrets encrypts sensitive values (app/db env blobs) at rest with AES-GCM. The master key lives in <dataDir>/keys/master.key (0600), created on first boot; STACKR_MASTER_KEY (64 hex chars) overrides it so the key can live apart from the database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
Decrypt reverses Encrypt. Values without the prefix (legacy plaintext) pass through unchanged.
func Encrypt ¶
Encrypt returns "enc:<base64(nonce||ciphertext)>". Empty and already encrypted input pass through unchanged.
func Generate ¶
Generate mints a random string of exactly length characters from letters plus the opted-in classes, the generator behind `default: generated` config secrets. Same panic rule as RandomHex.
func Key ¶
func Key() string
Key returns the master key in the same hex form the key file holds, so a backup can write it back out verbatim. Empty before Load.
func Load ¶
Load initializes the cipher from STACKR_MASTER_KEY or the key file at path, generating the file if absent.
func RandomHex ¶
RandomHex is n cryptographically random bytes, hex-encoded, the generator behind every credential stackr mints for itself: db passwords, registry passwords, webhook tokens, invite tokens.
It panics rather than returning an error. A machine that cannot produce randomness must not go on to hand out a guessable password, and every caller would otherwise write the same "if err != nil { panic }" it replaces.
Types ¶
This section is empty.