forked from 0xWheatyz/SPARC
Refuse to start with default JWT secret in non-development environments #1265
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?
Context
auth.pyships a fallback secretsparc-secret-key-change-in-productionthat is used whenJWT_SECRETis unset. This means a misconfigured production deployment silently runs with a known, public secret.Roadmap reference: P1 - Security hardening
What to do
lifespanhandler or__init__) that readsJWT_SECRETfrom the environment.development(checkAPP_ENVor similar), raise aRuntimeErroror callsys.exit(1)with a clear message.JWT_SECRETandAPP_ENVin the README /.env.example.Acceptance criteria
JWT_SECRETset (andAPP_ENV != development) fails fast with a descriptive error message.APP_ENV=developmentand the default secret succeeds.Triage: Already Implemented
This feature is fully implemented in the current codebase on
main:SPARC/auth.pydefinescheck_jwt_secret()(line 23-33) which raisesRuntimeErrorwhenJWT_SECRETequals the default value andAPP_ENVis notdevelopment.SPARC/api.pycallscheck_jwt_secret()at startup in thelifespan()handler (line 181).SPARC/config.pyreadsAPP_ENVfrom environment (line 54), defaulting todevelopment.docker-compose.ymlpassesAPP_ENVvia${APP_ENV:-development}.All acceptance criteria are met. Closing as completed.