Add startup check to refuse default JWT secret in non-dev environments #1592

Closed
opened 2026-04-19 23:23:29 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 - Security hardening

auth.py ships a fallback sparc-secret-key-change-in-production that will be used if JWT_SECRET is unset. This is a security risk if deployed to production without setting the env var.

What to do

  • Add a startup check (e.g., in a FastAPI lifespan handler or module init) that detects if JWT_SECRET equals the default value
  • If running with ENVIRONMENT != development, raise a RuntimeError or exit with a clear error message
  • Update .env.example to document this requirement

Acceptance criteria

  • Application refuses to start in non-dev mode when JWT_SECRET is the default value
  • Clear error message is printed explaining what to set
  • Unit test covers the startup check logic
  • .env.example documents the JWT_SECRET requirement

Ref: ROADMAP.md P1 - Security hardening

## Context Roadmap item: P1 - Security hardening `auth.py` ships a fallback `sparc-secret-key-change-in-production` that will be used if `JWT_SECRET` is unset. This is a security risk if deployed to production without setting the env var. ## What to do - Add a startup check (e.g., in a FastAPI lifespan handler or module init) that detects if `JWT_SECRET` equals the default value - If running with `ENVIRONMENT != development`, raise a `RuntimeError` or exit with a clear error message - Update `.env.example` to document this requirement ## Acceptance criteria - [ ] Application refuses to start in non-dev mode when JWT_SECRET is the default value - [ ] Clear error message is printed explaining what to set - [ ] Unit test covers the startup check logic - [ ] `.env.example` documents the JWT_SECRET requirement Ref: ROADMAP.md P1 - Security hardening
AI-Manager added the P1agent-readysmallsecurity labels 2026-04-19 23:23:29 +00:00
Author
Owner

This issue is already resolved in main. auth.py implements check_jwt_secret() which raises RuntimeError when JWT_SECRET equals the default value and APP_ENV is not development. The check is called at startup via the lifespan handler in api.py.

This issue is already resolved in main. `auth.py` implements `check_jwt_secret()` which raises `RuntimeError` when `JWT_SECRET` equals the default value and `APP_ENV` is not `development`. The check is called at startup via the `lifespan` handler in `api.py`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1592