secrets

command
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Example: Secret encryption with key rotation and historical audit retention.

Unlike user PII (which is pinned to 1 DEK and destroyed for GDPR erasure), application secrets (e.g. API tokens, third-party webhook secrets, credentials) require periodic rotation while preserving the ability to decrypt historical records.

Workflow:

  1. Secret v1 is created: store.CreateKey(ctx, conn, "api_token", "stripe")
  2. Payloads are encrypted under v1.
  3. When credentials rotate (e.g. 90-day policy), call store.RotateKey(ctx, conn, "api_token", "stripe"). - Atomically soft-revokes version 1 (revoked_at = NOW()) and inserts DEK version 2.
  4. New writes automatically use active key version 2.
  5. Historical events/receipts encrypted under version 1 remain decryptable by fetching key version 1 explicitly: store.GetKey(ctx, conn, "api_token", "stripe", 1).

Jump to

Keyboard shortcuts

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