Add startup check to reject default JWT secret in production #637

Closed
opened 2026-03-28 12:21:32 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Security Hardening

auth.py ships a fallback secret sparc-secret-key-change-in-production that will be used if JWT_SECRET is unset. This is a security risk in production deployments.

What to do

  • In auth.py, on application startup, check whether JWT_SECRET is set to the default value
  • If it is the default AND the environment is not development (check APP_ENV or ENVIRONMENT env var), raise a fatal error and refuse to start
  • Add APP_ENV (default: production) to config.py and document it in .env.example

Acceptance criteria

  • The application starts normally in dev mode with the default secret
  • The application refuses to start in production mode when JWT_SECRET is the default value, logging a clear error message
  • APP_ENV=development is documented in .env.example or equivalent
## Context Roadmap item: P1 Security Hardening `auth.py` ships a fallback secret `sparc-secret-key-change-in-production` that will be used if `JWT_SECRET` is unset. This is a security risk in production deployments. ## What to do - In `auth.py`, on application startup, check whether `JWT_SECRET` is set to the default value - If it is the default AND the environment is not `development` (check `APP_ENV` or `ENVIRONMENT` env var), raise a fatal error and refuse to start - Add `APP_ENV` (default: `production`) to `config.py` and document it in `.env.example` ## Acceptance criteria - The application starts normally in dev mode with the default secret - The application refuses to start in production mode when `JWT_SECRET` is the default value, logging a clear error message - `APP_ENV=development` is documented in `.env.example` or equivalent
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 12:21:32 +00:00
Author
Owner

Closing as already implemented. SPARC/auth.py contains _check_jwt_secret() which rejects the default JWT secret when APP_ENV is not development. The .env.example documents this behavior.

Closing as already implemented. `SPARC/auth.py` contains `_check_jwt_secret()` which rejects the default JWT secret when `APP_ENV` is not `development`. The `.env.example` documents this behavior.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#637