Skip to content

secure JWT secrets via environment variables#577

Merged
Wilfred007 merged 1 commit intoGildado:mainfrom
kryputh:codex/secure-jwt-env-vars
Apr 22, 2026
Merged

secure JWT secrets via environment variables#577
Wilfred007 merged 1 commit intoGildado:mainfrom
kryputh:codex/secure-jwt-env-vars

Conversation

@kryputh
Copy link
Copy Markdown
Contributor

@kryputh kryputh commented Apr 22, 2026

Closes #367

Summary

  • remove hardcoded JWT access and refresh secret fallbacks from backend env parsing
  • require strong, non-placeholder JWT secrets from environment variables and ensure refresh secret differs from the access secret
  • add a Jest setup file that injects fresh test-only JWT secrets per run, plus unit coverage for the new validation rules
  • update backend and deployment docs to explain secret generation and rotation through platform environment settings

Root Cause

The backend accepted hardcoded JWT defaults in backend/src/config/env.ts, which allowed deployments to start with committed fallback secrets instead of platform-managed values.

Validation

  • npx jest --config jest.config.cjs --runTestsByPath src/config/__tests__/env.test.ts --runInBand
  • npx eslint src/config/env.ts src/config/__tests__/env.test.ts
  • npx tsc --noEmit --module nodenext --moduleResolution nodenext --target es2022 --esModuleInterop true --types jest,node src/config/env.ts src/config/__tests__/env.test.ts jest.setup.ts

Repo Baseline Issues

  • npm ci currently fails because backend/package-lock.json is out of sync with backend/package.json
  • npm run build and npm run lint currently fail on pre-existing repo-wide TypeScript and ESLint issues outside this change

Refs: #367

@kryputh kryputh changed the title [codex] secure JWT secrets via environment variables secure JWT secrets via environment variables Apr 22, 2026
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 22, 2026

@kryputh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Wilfred007 Wilfred007 marked this pull request as ready for review April 22, 2026 17:44
@Wilfred007 Wilfred007 merged commit c8a5d04 into Gildado:main Apr 22, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#160: Secure JWT Keys with Environment Variables

2 participants