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:
- Secret v1 is created: store.CreateKey(ctx, conn, "api_token", "stripe")
- Payloads are encrypted under v1.
- When credentials rotate (e.g. 90-day policy), call store.RotateKey(ctx, conn, "api_token", "stripe"). - Inserts DEK version 2. - Soft-revokes version 1 (revoked_at = NOW()).
- New writes automatically use active key version 2.
- Historical events/receipts encrypted under version 1 remain decryptable by fetching key version 1 explicitly: store.GetKey(ctx, conn, "api_token", "stripe", 1).
Click to show internal directories.
Click to hide internal directories.