Skip to content

feat(api): zero-downtime CHECKIN_ENCRYPTION_KEY rotation - #863

Merged
unjica merged 1 commit into
developfrom
feat/checkin-key-rotation
Oct 22, 2026
Merged

unjica merged 1 commit into
developfrom
feat/checkin-key-rotation

Conversation

@unjica

@unjica unjica commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Adds safe rotation of the check-in encryption key without data loss.

  • CHECKIN_ENCRYPTION_KEY = current key (all new encryption). Optional CHECKIN_ENCRYPTION_KEY_PREVIOUS (comma-separated) = decrypt-only fallback.
  • New ciphertext: v1.<kid>.<base64(iv|tag|ct)>, kid = 16-hex SHA-256 fingerprint of the key. Legacy bare-base64 rows still decrypt (current, then previous keys; AES-256-GCM auth rejects wrong keys).
  • node dist/jobs/run-checkin-reencrypt.js [--apply] [--batch-size n]: dry-run by default, batched, idempotent, compare-and-set updates, verifies token hash, prints counts only.
  • Tests for old-key decryption, new-key writes, migration + idempotency, missing/malformed previous key.
  • Runbook in docs/CHECK-INS.md. No DB migration; backward compatible.

@unjica
unjica merged commit dfc17fd into develop Oct 22, 2026
7 of 8 checks passed
@unjica unjica mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant