ADR 0004 — Token encryption key separated from the database

Status

Accepted

Context

MAIL-74 must store provider OAuth tokens so later connect/refresh/revoke work can persist credentials. NFR §7 and Technical Architecture §§58–60 require tokens never to appear in git, logs, client storage, or plaintext at rest. Deployment §45 requires application-level protection beyond database access: the database holds ciphertext; the encryption key is managed separately.

TOKEN_ENCRYPTION_KEY is already a fail-closed boot requirement (MAIL-72 / packages/config/src/env.ts). Sprint 01 must not invent a cloud KMS.

Decision

Alternatives considered

Consequences