-
Notifications
You must be signed in to change notification settings - Fork 24
Auto Refresh Token #5535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Auto Refresh Token #5535
Conversation
- Added middleware to handle access and refresh token management, including extraction from cookies and token expiration checks. - Introduced GraphQL mutation for refreshing tokens and updated cookie handling for user settings. - Refactored cookie utility functions to support new token management strategy. - Updated various components to utilize new token handling methods, ensuring proper authentication flow. - Enhanced user experience by automatically refreshing tokens and managing session state effectively.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
E2E Test Report: ❌ FAILEDBranch: Deployed with Cloudflare Pages at 2025-06-23T16:16:15.952Z |
…d user metadata cookies
E2E Test Report: ❌ FAILEDBranch: View Branch-specific E2E Report Deployed with Cloudflare Pages at 2025-06-24T10:42:04.281Z |
…g unnecessary date calculations
E2E Test Report: ❌ FAILEDBranch: View Branch-specific E2E Report Deployed with Cloudflare Pages at 2025-06-24T10:59:57.432Z |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Null Assertion Error in Token Expiration Handling
The middleware uses non-null assertion operators on accessTokenExpiration and refreshTokenExpiration, which are the results of getTokenExpiration(). Since getTokenExpiration() can return null for malformed or invalid JWTs, using these null values with new Date() or .toString() will cause runtime errors when setting cookie expiration dates, potentially crashing the middleware.
src/middleware.ts#L129-L144
Lines 129 to 144 in fa06df2
| // Set new tokens in response | |
| const accessTokenExpiration = getTokenExpiration(newTokens.accessToken) | |
| const refreshTokenExpiration = getTokenExpiration(newTokens.refreshToken) | |
| response.cookies.set(COOKIE_ACCESS_TOKEN, newTokens.accessToken, { | |
| ...cookieOptions, | |
| expires: new Date(accessTokenExpiration!), | |
| }) | |
| response.cookies.set(COOKIE_REFRESH_TOKEN, newTokens.refreshToken, { | |
| ...cookieOptions, | |
| expires: new Date(refreshTokenExpiration!), | |
| }) | |
| response.cookies.set( | |
| COOKIE_ACCESS_TOKEN_EXPIRES_AT, | |
| accessTokenExpiration!.toString(), | |
| { ...cookieOptions, httpOnly: false } | |
| ) |
Was this report helpful? Give feedback by reacting with 👍 or 👎
E2E Test Report: ❌ FAILEDBranch: View Branch-specific E2E Report Deployed with Cloudflare Pages at 2025-06-24T11:15:34.271Z |
E2E Test Report: ✅ PASSEDBranch: View Branch-specific E2E Report Deployed with Cloudflare Pages at 2025-06-25T00:50:14.368Z |
<TokenExpirationChecker>and Next.js Middleware to check and refresh tokens;Note: There is currently no error handler for the refresh token in Apollo GraphQL, as we expect the existing auto-refresh mechanism to cover all edge cases.