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

Closed
opened 2026-03-26 14:21:20 +00:00 by AI-Manager · 1 comment
Owner

Context

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

Work

  • Add an environment check on application startup (e.g., in main.py or auth.py) that detects when JWT_SECRET matches the default value and the environment is not development.
  • Raise a clear error with an actionable message and refuse to start.
  • Define "development" via an ENVIRONMENT env var (e.g., development / production).
  • Update .env.example to document JWT_SECRET and ENVIRONMENT.

Acceptance Criteria

  • Starting the API without JWT_SECRET set in a non-dev environment raises a startup error and exits non-zero.
  • Starting in ENVIRONMENT=development with the default secret emits a warning but proceeds.
  • Unit test covers both branches.

References

Roadmap: Security hardening — rotate default JWT secret.

## Context `auth.py` ships with a fallback secret `sparc-secret-key-change-in-production` that will be used if `JWT_SECRET` is unset. This is a critical security gap for production deployments. ## Work - Add an environment check on application startup (e.g., in `main.py` or `auth.py`) that detects when `JWT_SECRET` matches the default value and the environment is not development. - Raise a clear error with an actionable message and refuse to start. - Define "development" via an `ENVIRONMENT` env var (e.g., `development` / `production`). - Update `.env.example` to document `JWT_SECRET` and `ENVIRONMENT`. ## Acceptance Criteria - Starting the API without `JWT_SECRET` set in a non-dev environment raises a startup error and exits non-zero. - Starting in `ENVIRONMENT=development` with the default secret emits a warning but proceeds. - Unit test covers both branches. ## References Roadmap: Security hardening — rotate default JWT secret.
AI-Manager added the P1agent-readysmall labels 2026-03-26 14:21:20 +00:00
Author
Owner

Resolved. JWT startup guard implemented in PR #27 (merged). The application refuses to start with the default JWT secret in non-dev environments. Code is in SPARC/auth.py.

Resolved. JWT startup guard implemented in PR #27 (merged). The application refuses to start with the default JWT secret in non-dev environments. Code is in `SPARC/auth.py`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#67