Documentation
¶
Overview ¶
Package bundler makes and restores an age-encrypted backup. bundle tars {private keys + manifest + inventory + providers.json} (NEVER .env) and age-encrypts it with a SHA256 sidecar + a contents list; restore decrypts and lays the SAME keys back (same fingerprint). The cipher is behind a seam (Cipher) so tests inject a fake and the tar / lay-down / fingerprint guarantees are verifiable without age installed.
Plaintext never touches the disk. The tar is piped straight into age and the decrypted stream is read into memory and written to its final destination, so there is no staging copy in $TMPDIR - which is world-traversable, often on a different filesystem, and outlives a crash.
Index ¶
Constants ¶
const ( BundlePrefix = "authama-" LegacyBundlePrefix = "ssh-manager-" )
BundlePrefix starts every bundle file name. Bundles written before 0.1.1 are named with LegacyBundlePrefix and are still listed, pruned and restorable.
Variables ¶
This section is empty.
Functions ¶
func BackupBeforeDestroying ¶
BackupBeforeDestroying writes an age-encrypted bundle so an operation that destroys key material stays recoverable.
This used to be free: the pre-mutation snapshot tarred every private key, so anything destroyed could be dug back out of it. Snapshots no longer carry keys - deliberately, they were a rolling plaintext archive - which means the destructive paths need a real backup of their own. An encrypted bundle is the replacement, and no configured recipient is a hard stop rather than a shrug, because the alternative is losing a key with no way back.
func FinishRestore ¶
FinishRestore re-asserts perms on the restored tree and config-home secrets, then re-renders the config. The bundle does not carry the rendered files, so without the render ~/.ssh has no category configs; a failure is returned rather than dropped.
Types ¶
type AgeCipher ¶
type AgeCipher struct{}
AgeCipher shells out to age (X25519 + ChaCha20-Poly1305) over stdin/stdout.
type BundleResult ¶
BundleResult summarizes a bundle run.
func (BundleResult) Format ¶
func (r BundleResult) Format() string
Format renders the bundle summary (mirrors BundleResult.format).
type Bundler ¶
type Bundler struct {
// contains filtered or unexported fields
}
Bundler makes/restores bundles.
func (*Bundler) Bundle ¶
func (b *Bundler) Bundle(recipient, destDir, stamp string) (BundleResult, error)
Bundle tars the keys + config models, encrypts to dest/authama-<stamp>.age, and writes the .sha256 + .contents sidecars. The tar is piped directly into the cipher, so the plaintext archive exists only in memory.
func (*Bundler) Restore ¶
func (b *Bundler) Restore(bundlePath, identityFile string, fingerprintOf func(string) (string, error)) (RestoreResult, error)
Restore decrypts bundlePath and lays the same keys back down (verifying the SHA256 sidecar first). fingerprintOf fingerprints each restored .pub.
The decrypted stream is read into memory and written straight to its final destination. Reading it whole before writing anything also means a corrupt or wrongly-keyed bundle is rejected before it has half-overwritten the tree.
type Cipher ¶
type Cipher interface {
Encrypt(dst io.Writer, src io.Reader, recipient string) error
Decrypt(dst io.Writer, src io.Reader, identityFile string) error
}
Cipher transforms a stream. It is deliberately stream-shaped rather than file-shaped: a file-based cipher forces the caller to stage plaintext on disk.
type FP ¶
type FP struct{ Name, Fingerprint string }
FP is one restored key's fingerprint (ordered by lay-down).
type RestoreResult ¶
type RestoreResult struct {
Restored []string
Fingerprints []FP
// Skipped lists rendered files an older (or forged) bundle carried, which
// restore does not lay down: the caller re-renders them from the manifest.
Skipped []string
}
RestoreResult summarizes a restore run.
func (RestoreResult) Format ¶
func (r RestoreResult) Format() string
Format renders the restore summary (mirrors RestoreResult.format).