forked from 0xWheatyz/SPARC
Refuse startup with default JWT secret in non-dev environments #202
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 fallbacksparc-secret-key-change-in-productionvalue that is used whenJWT_SECRETis unset. If this secret reaches production, all tokens are trivially forgeable.Roadmap reference: ROADMAP.md > P1 > Security hardening
What to do
auth.pymodule init), readJWT_SECRETfrom the environment.ENV/ENVIRONMENTvariable is NOTdevelopmentordev, raise aRuntimeErrorwith a clear message and refuse to start.Acceptance criteria
JWT_SECRETset in aproductionenvironment exits with a descriptive error.developmentmode succeeds (or at minimum does not crash).This issue has already been resolved in the current codebase.
auth.pycontainscheck_jwt_secret()(lines 23-33) which raises aRuntimeErrorwhenJWT_SECRETequals the default value andAPP_ENVis notdevelopment. The function is called during app startup via the lifespan handler.Closing as already implemented.