Repository navigation
fix: handle expired sessions safely across console tabs - #300
Merged
Merged
Conversation
Scope failure callbacks and client readiness to their STS session so delayed requests cannot erase a replacement login. Unify API and S3 authentication errors, detect idle expiration, and preserve explicit OIDC logout.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical cross-tab race allows logout to delete replacement login credentials and the OIDC token because the session check and deletion are not atomic across tabs.
1 open issue
What changed in this PR
This PR addresses #299 by improving expired-session handling across Console tabs, Admin requests, and S3 requests while preserving manual OIDC logout.
Changes:
- Recognizes session errors consistently and checks the current session before invalidation.
- Persists credentials synchronously, hides outdated clients, and checks expiration during idle periods and browser restoration.
- Shows the expiration warning once and expands regression coverage.
| File | Description |
|---|---|
tests/lib/s3-error-middleware.test.ts |
Adds SDK-backed error and response coverage. |
tests/lib/form-interaction.test.ts |
Tests expiration warnings and recovered-session redirects. |
tests/lib/auth-session.test.ts |
Tests credential validity and session identity. |
tests/lib/api-client.test.ts |
Covers authentication errors and permission handling. |
tests/hooks/use-oidc-logout.test.ts |
Expands cross-tab, timer, persistence, and logout coverage. |
lib/s3-error-middleware.ts |
Extracts S3 error handling and propagates session failures. |
lib/auth-session.ts |
Adds shared session validation and error classification. |
lib/api-client.ts |
Unifies Admin authentication-error handling. |
hooks/use-local-storage.ts |
Makes persistence synchronous and reloads current storage values. |
contexts/s3-context.tsx |
Binds S3 clients and invalidation to session credentials. |
contexts/auth-context.tsx |
Adds conditional invalidation and automatic expiration checks. |
contexts/api-context.tsx |
Guards stale callbacks and exposes matching clients only. |
app/(auth)/auth/login/page.tsx |
Prevents duplicate or obsolete expiration warnings. |
Review effort: Balanced
Comment on lines
+234
to
+235
| if (loggingOutRef.current || !isCurrentSession(expected)) return false | ||
| logout() |
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
Expired STS credentials could leave Console on an error page, and a delayed request from another tab could delete a newly established session. Authentication failures now invalidate only the session that signed the request, and idle sessions return to Login with the existing expiration notice.
InvalidAccessKeyId,ExpiredToken(including HTTP 400), and existing unauthorized responses consistently in Admin and S3 clients. Permission errors retain their normal handling.Type of Change
Testing
All checks passed; 1,059 tests passed. Regression coverage includes delayed API/S3 errors and timers before/after storage events, replacement-client readiness, JSON/XML authentication errors, ordinary AccessDenied, storage failures, idle expiration, and OIDC logout. S3 tests exercise the real AWS SDK with simulated HTTP responses.
Chrome validation against a local simulated RustFS API covered expired bucket refresh, a 10-second idle session at a 390 × 844 mobile viewport, and two tabs retaining the replacement session after an old request's delayed 403 was released.
Checklist
Related Issues
Closes #299
Screenshots (if applicable)
Browser captures use the local simulated API described above. The desktop pair shows the same expired bucket-refresh flow before and after the fix; additional captures cover idle mobile expiration and both tabs after the delayed old response.
Desktop expired refresh, before / after:
Idle expiration on mobile:
Both tabs after releasing the old request’s delayed 403:
Additional Notes
Independent correctness, test, simplification, and UX reviews were completed. No live RustFS VM deployment or Firefox/Authelia OIDC integration run was performed.