Secure jwt authentication#741
Conversation
|
@Srushti-Kamble14 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
Priyanshu-byte-coder
left a comment
There was a problem hiding this comment.
Critical issues — cannot merge:
-
Merge conflict markers: Raw
<<<<<<< HEAD/=======/>>>>>>>still present indashboard/page.tsx. Rebase and resolve. -
Leaderboard page overwritten:
leaderboard/page.tsxis replaced with a copy of the dashboard page, deleting all leaderboard functionality. Revert this change. -
Test bypass in production code: The
PLAYWRIGHT_AUTH_BYPASScheck lives inside the page server component. Test-only bypasses must stay in middleware or be compiled out — not shipped in page logic. -
GET on token refresh endpoint: The refresh route exports
GET = POST. Refresh endpoints must only accept POST — GET is CSRF-vulnerable via link prefetching and image tags. -
Missing EOF newlines on
leaderboard/page.tsxandExportButton.tsx.
Changes Made
|
|
Several architectural issues block this merge: 1. 2. Tokens are created but never validated 3. Reuses 4. Design concern The JWT signing/verification implementation in |
|
Deployment failed with the following error: |
c96b09d to
11b4a93
Compare
|
I have addressed the architectural issues and lint errors holding up PR #741. Here is a summary of the fixes implemented on the local pr-741 branch and pushed to your fork (origin/pr-741): cookies().set() Server Component Error: I removed the token creation logic from src/app/dashboard/page.tsx. Next.js App Router strictly forbids setting cookies in Server Components, so this completely resolves the runtime crash. |
|
Closing: this adds the same parallel JWT access/refresh token system on top of NextAuth as PR #877 which was already closed for the same reason. NextAuth already handles secure session management via httpOnly JWTs. Adding a second token layer without a clear use case significantly increases the attack surface. If there's a specific use case that NextAuth doesn't cover, please open an issue to discuss the approach first. |
Summary
Implemented a secure JWT-based authentication system using Access Tokens and Refresh Tokens for DevTrack.
This improves authentication security, enables secure session management, and provides a smoother user experience by preventing repeated logins after token expiration.
Closes #421
Type of Change
Changes Made
How to Test
Clone the repository and install dependencies
Run the application locally
Register or log in with valid credentials
Verify Access Token is generated after login
Access protected routes using authenticated requests
Wait for Access Token expiration
Verify Refresh Token generates a new Access Token automatically
Confirm user session remains active without re-login
Test invalid or expired tokens to ensure unauthorized access is blocked
Checklist
npm run lintpasses locallynpm run type-check)