forked from 0xWheatyz/SPARC
Refuse startup with default JWT secret in non-dev environments #611
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-productionused whenJWT_SECRETis unset. If this secret reaches production, all tokens issued can be forged by anyone who reads the source code.Roadmap item: P1 > Security hardening
What to do
main.pylifespan or an__init__guard) that reads the active JWT secret.development(check anAPP_ENVorENVIRONMENTvariable), raise aRuntimeErroror log aCRITICALmessage andsys.exit(1).JWT_SECRETenv var inREADME.mdand.env.example.Acceptance criteria
APP_ENV=productionexits with a clear error message.APP_ENV=development(or unset) still works with the default secret for local dev.Closing: already implemented on main.
check_jwt_secret()inauth.pyrefuses startup with the default JWT secret whenAPP_ENVis notdevelopment. Theapp_envconfig is inconfig.pyand.env.exampledocuments the variable.