Skip to content

feat(security): separate JWT access and refresh secrets and add authMiddleware test suite (Fixes #19, Fixes #32, Fixes #33) - #148

Open
Sanjai-Gopal wants to merge 3 commits into
sidd190:mainfrom
Sanjai-Gopal:feat/distinct-jwt-secrets-and-authmiddleware-tests
Open

Sanjai-Gopal wants to merge 3 commits into
sidd190:mainfrom
Sanjai-Gopal:feat/distinct-jwt-secrets-and-authmiddleware-tests

Conversation

@Sanjai-Gopal

@Sanjai-Gopal Sanjai-Gopal commented Nov 16, 2026 •

Copy link
Copy Markdown

Summary

Fixes #19, Fixes #32, and Fixes #33. Separates JWT access and refresh secrets to prevent privilege cross-contamination and introduces dedicated test coverage for authentication middleware.

Changes

  • Distinct Secrets: Replaced single shared JWT secret with dedicated JWT_ACCESS_SECRET and JWT_REFRESH_SECRET.
  • Middleware Guard: authMiddleware validates token type and rejects refresh tokens submitted to access-protected routes.
  • Unit Test Suite: Added comprehensive authMiddleware.test.js verifying valid Bearer tokens, expired tokens, missing headers, and cross-secret rejection.

Verification

  • npx jest backend/__tests__/authMiddleware.test.js: 100% pass rate.
  • npm test: All suites pass without errors.
  • npm run lint: Clean ESLint status.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 76b62c2c-44d0-4531-b925-2d6276b2b995
Commits

Reviewing files that changed from the base of the PR and between 805e9f4 and 212721c.

Files ignored due to path filters: 1

  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing: 5

  • backend/__tests__/authMiddleware.test.js
  • backend/__tests__/secretEnforcement.test.js
  • backend/index.js
  • backend/middleware/auth.js
  • package.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Sanjai-Gopal Sanjai-Gopal changed the title Feat/distinct jwt secrets and authmiddleware tests feat(security): separate JWT access and refresh secrets and add authMiddleware test suite (Fixes #19, Fixes #32, Fixes #33) Nov 18, 2026
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.

Refuse insecure default secrets in production Use a distinct refresh-token secret Add tests for authMiddleware

1 participant