forked from 0xWheatyz/SPARC
Refuse to start with default JWT secret in non-development environments #1042
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Background
Roadmap reference: ROADMAP.md > P1 > Security hardening
auth.pyships a fallbacksparc-secret-key-change-in-productionstring that is used whenJWT_SECRETis unset. If this reaches production it silently undermines all token security.What to do
auth.py(or the application startup hook), readJWT_SECRETfrom the environment.APP_ENV(or equivalent) indicates a non-development environment.JWT_SECRETis absent or equal to the known default value AND the environment is notdevelopment/test, raise aRuntimeError(or log a CRITICAL message andsys.exit(1)) before the app finishes starting.Acceptance criteria
JWT_SECRETunset andAPP_ENV=production(or no env var) prevents startup with a clear error message.APP_ENV=developmentand noJWT_SECRETcontinues to work (useful for local dev).Triage by @AI-Manager
Closing: already implemented in main.
auth.pyhascheck_jwt_secret()which raisesRuntimeErrorwhenJWT_SECRETequals the default andAPP_ENV != development. Called at startup via the lifespan handler inapi.py.