-
Notifications
You must be signed in to change notification settings - Fork 0
Release #15
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
Release #15
Conversation
feat: Implement token renewal service and integrate with authenticati…
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.
Pull Request Overview
This pull request introduces a comprehensive token renewal system for MSAL authentication to improve session persistence and user experience. The implementation includes automatic token refresh capabilities, enhanced error recovery, and better session management.
Key changes:
- Added automated token renewal service that proactively refreshes tokens every 30 minutes
- Enhanced authentication error handling with interactive fallback for token acquisition failures
- Improved session persistence by enabling cookie-based authentication state storage
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/utils/authErrorHandler.ts | Adds utility function to identify recoverable authentication errors |
| frontend/services/userDataService.ts | Enhances token acquisition with interactive popup fallback on silent renewal failure |
| frontend/services/tokenRenewalService.ts | Implements comprehensive token renewal service with periodic refresh and error handling |
| frontend/hooks/useTokenRenewal.ts | Provides React hook to automatically manage token renewal based on authentication state |
| frontend/authConfig.ts | Enables cookie-based authentication state storage for better session persistence |
| frontend/App.tsx | Integrates token renewal hook into main application component |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| private isTokenNearExpiry(_account: any): boolean { | ||
| // Always attempt renewal for proactive refreshing | ||
| // MSAL handles token expiry checks internally, so we'll rely on forceRefresh | ||
| return true; | ||
| } |
Copilot
AI
Oct 1, 2025
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.
This method always returns true, making it essentially a no-op. Consider either implementing actual token expiry logic or removing this method and directly using the boolean value where it's called.
| /** | ||
| * Check if the current token is near expiry | ||
| */ | ||
| private isTokenNearExpiry(_account: any): boolean { |
Copilot
AI
Oct 1, 2025
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.
The parameter is prefixed with underscore but typed as any. Consider using a proper type from MSAL (e.g., AccountInfo) or if the parameter is truly unused, remove it entirely.
|
🎉 This PR is included in version 2.3.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This pull request introduces a robust token renewal system for MSAL authentication, improving session persistence and user experience. It adds a service that proactively refreshes authentication tokens at regular intervals and recovers from authentication errors with interactive prompts when needed. Additionally, session persistence is enhanced by storing authentication state in cookies.
Authentication Token Renewal & Error Handling Improvements:
tokenRenewalServiceinfrontend/services/tokenRenewalService.tsthat periodically refreshes MSAL tokens every 30 minutes and handles silent/interactive renewal flows, ensuring users stay authenticated without manual intervention.useTokenRenewalReact hook (frontend/hooks/useTokenRenewal.ts) that automatically starts or stops the token renewal service based on the user's authentication state, and integrated it into the mainAppcomponent. [1] [2]getAccessToken(frontend/services/userDataService.ts) to attempt interactive token acquisition via popup if silent renewal fails, using a new utilityisRecoverableAuthErrorfor better recovery from authentication issues.Session Persistence Enhancement:
storeAuthStateInCookie: true) for improved session persistence across browser sessions.Authentication Error Utilities:
isRecoverableAuthErrorutility tofrontend/utils/authErrorHandler.tsto detect when interactive authentication is required and enable fallback to popup/redirect flows.