fix(security): remove fallback JWT secrets - #398
Open
Blaqkenny wants to merge 1 commit into
Open
Conversation
Replace the hard-coded `|| 'supersecret'` / `|| 'your-secret-key'` fallbacks in the admin module, admin JWT strategy and user JWT strategy with required configuration resolution (`ConfigService.getOrThrow`), so startup fails when JWT_SECRET is absent instead of silently using a predictable secret. Adds tests proving the strategies cannot be constructed without a configured secret and never fall back to a predictable default. Closes UnityChainxx#250 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@Blaqkenny 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves the Stellar Wave issue assigned to Blaqkenny.
Changes
backend/src/admin/admin.module.ts— replacedJwtModule.register({ secret: process.env.JWT_SECRET || 'supersecret' })withJwtModule.registerAsyncresolvingJWT_SECRETviaConfigService.getOrThrow.backend/src/admin/strategies/jwt.strategy.ts— replacedprocess.env.JWT_SECRET || 'supersecret'withConfigService.getOrThrow('JWT_SECRET').backend/src/auth/strategies/jwt.strategy.ts— replacedconfigService.get('JWT_SECRET') || 'your-secret-key'withConfigService.getOrThrow('JWT_SECRET').No hard-coded/predictable secrets remain: startup now fails fast when
JWT_SECRETis absent (global Joi validation already requires it, and every consumer now resolves it without a fallback).Tests
jwt.strategy.spec.tsfor both admin and user strategies proving the strategy cannot be constructed whenJWT_SECRETis missing/empty, and that the resolved secret is exactly the configured value (never a predictable default).config-validation.spec.tsalready proves the app config rejects a missingJWT_SECRET.Closes #250