fix(config): refuse dev JWT_SECRET/ENCRYPTION_KEY outside dev/test (PMS-499) #378
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PMS-499-guard-dev-secrets-in-prod"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
AppConfig::from_env silently fell back to the hardcoded dev constants for JWT_SECRET and ENCRYPTION_KEY in any environment, so a production or staging deployment that forgot to set them (or copied the dev defaults) booted with a publicly-known signing secret and at-rest encryption key.
Resolve both secrets through a new resolve_secret helper before the struct is built. In development/dev/test an unset var still falls back to the dev constant. In every other environment (production, staging, or any unrecognized value, which fails safe) an unset var - or one explicitly set to the known dev constant - is now a fatal boot error, mirroring the existing fail-loud SMTP/Google/migrations startup checks. Adds unit tests covering the dev fallback, the unset-in-prod error, the explicit-dev-value-in-prod error, and the real-secret-accepted path.
#PMS-499