Repository navigation
fix(auth): prevent redirects from interrupting OIDC logout - #292
Merged
Merged
Conversation
Keep federated logout in progress until its full-page navigation completes so dashboard guards and stale API or S3 errors cannot cancel the IdP redirect. Add behavioral regression coverage and a recovery link for cancelled navigation.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A new session received through cross-tab storage events leaves the logout flag set, preventing subsequent logout and keeping API/S3 authentication redirects disabled.
1 open issue
What changed in this PR
Addresses #289 by preventing automatic Console redirects from interrupting OIDC logout before the browser reaches the identity provider.
Changes:
- Adds a synchronous logout flag to suppress dashboard and API/S3 redirects and prevent duplicate logout attempts.
- Adds a Back to Login recovery link and back-forward cache recovery that preserves newer sessions.
- Replaces source-pattern checks with 19 behavior tests covering logout races, fallbacks, and recovery.
| File | Description |
|---|---|
tests/lib/oidc-logout-source.test.js |
Removes source-pattern logout checks. |
tests/hooks/use-permissions-refresh.test.ts |
Updates the auth mock with the logout-state getter. |
tests/hooks/use-oidc-logout.test.ts |
Adds logout navigation and recovery behavior tests. |
contexts/s3-context.tsx |
Suppresses S3 authentication redirects during logout. |
contexts/auth-context.tsx |
Tracks logout progress, blocks duplicates, and handles cached-page restoration. |
contexts/api-context.tsx |
Suppresses API error redirects during logout. |
components/dashboard-auth-guard.tsx |
Guards automatic redirects and adds a login recovery link. |
Review effort: Balanced
Reset logout protection when storage restores an authenticated session before consumer effects handle authentication errors. Keep pending logout protected against repeated credentials events and cover the cross-tab recovery behavior.
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.

Pull Request
Description
Clearing Console credentials during OIDC logout triggers dashboard and stale API/S3 error callbacks that can redirect to the login page before the pending logout navigation reaches the IdP. Guard those automatic redirects with a synchronous logout flag set before the first await, so local credentials can still be cleared while the browser follows the backend-to-IdP redirect chain.
Prevent duplicate logout attempts, retain the existing fallback when logout cannot start, and add a keyboard-accessible Back to Login link for interrupted navigation. Restore normal logout and authentication redirects when another tab signs in after an interrupted logout, without releasing protection for repeated credentials events during logout. Recover a dashboard restored from the back-forward cache without deleting a newer session established in another document.
Type of Change
Testing
Replaced the source-pattern logout test with 24 React behavior tests covering redirect races, stale API/S3 callbacks, duplicate logout, fallback errors, credential cleanup, recovery links, and back-forward cache restoration.
All checks passed with Node.js 22:
pnpm install --frozen-lockfile pnpm type-check pnpm lint pnpm format:check pnpm test:run # 946 passed, 0 failedChrome validation with a local mock backend and IdP:
Checklist
Related Issues
Closes #289
Screenshots (if applicable)
The pair below shows the state after deliberately cancelling a slow logout navigation. Before, the client redirects to login; after, the recovery link remains available without an automatic redirect taking over.
Mobile dark mode recovery state:
Additional Notes
Browser validation used a local mock IdP; real Keycloak integration has not been run. The screenshots demonstrate interrupted-navigation recovery, while the redirect race is covered by the behavior tests.