feat: enforce IPSIE session_expiry with a SESSION_EXPIRED error#1597
feat: enforce IPSIE session_expiry with a SESSION_EXPIRED error#1597subhankarmaiti wants to merge 7 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughChangesThe SDK adds optional IPSIE Session Expiry
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Auth0SPAJS
participant WebCredentialsManager
participant CredentialsManagerError
participant Credentials
Auth0SPAJS->>WebCredentialsManager: getTokenSilently()
WebCredentialsManager->>CredentialsManagerError: classify undefined token as session_expired
WebCredentialsManager->>Credentials: store validated session_expiry as sessionExpiresAt
WebCredentialsManager-->>Auth0SPAJS: return credentials or throw SESSION_EXPIRED
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/platforms/web/adapters/WebCredentialsManager.ts (1)
75-85: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winReplace changed
anycatch bindings withunknown.Lines 75, 116, and 133 catch errors as
anyeven though this file is under strict TypeScript. Cast/narrow to an error-like record before readingerror,error_description, andmessage.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/platforms/web/adapters/WebCredentialsManager.ts` around lines 75 - 85, Update the catch bindings in WebCredentialsManager to use unknown instead of any, including the handlers around the shown CredentialsManagerError conversion and the other catches at the referenced locations. Narrow each caught value to an error-like record before reading error, error_description, or message, while preserving the existing CredentialsManagerError rethrow and AuthError construction behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@EXAMPLES.md`:
- Around line 688-691: Update the session_expiry NOTE in EXAMPLES.md to state
that the ceiling is pinned at initial login only on Android. Preserve the
documented current-ID-token behavior for iOS and Web, and keep the no-claim
behavior unchanged.
In `@ios/NativeBridge.swift`:
- Around line 668-679: Update NativeBridge.saveCredentials() and its Credentials
reconstruction to preserve the optional NativeBridge.sessionExpiresAtKey value
exposed by Credentials.asDictionary(). Parse and pass the value through during
explicit saveCredentials() round trips, or explicitly reject credentials
containing it; do not silently discard the session expiration ceiling.
In `@README.md`:
- Around line 757-759: Add a SESSION_EXPIRED branch to the
CredentialsManagerErrorCodes error-handling switch in README.md, following the
clear-and-restart login flow documented in EXAMPLES.md. Keep existing cases and
generic fallback behavior unchanged.
In `@src/core/models/Credentials.ts`:
- Line 17: Add a JSDoc comment directly above the public
Credentials.sessionExpiresAt field, documenting it as the session-ceiling Unix
timestamp and stating that it is undefined when the ID token lacks the IPSIE
session_expiry claim.
In `@src/platforms/web/adapters/WebCredentialsManager.ts`:
- Around line 34-47: Update getApiCredentials to handle an undefined response
from getTokenSilently the same way as the existing token flow: throw
CredentialsManagerError wrapping AuthError with the session_expired code and
re-authentication message before accessing the response. Preserve the existing
handling for valid token responses.
In `@src/types/common.ts`:
- Around line 44-46: Update the JSDoc remarks for the affected property in
common.ts by separating the cross-platform availability/derivation description
from the Android-specific credentials-manager behavior, and label the latter
explicitly as “Android only” using the required JSDoc notation.
---
Outside diff comments:
In `@src/platforms/web/adapters/WebCredentialsManager.ts`:
- Around line 75-85: Update the catch bindings in WebCredentialsManager to use
unknown instead of any, including the handlers around the shown
CredentialsManagerError conversion and the other catches at the referenced
locations. Narrow each caught value to an error-like record before reading
error, error_description, or message, while preserving the existing
CredentialsManagerError rethrow and AuthError construction behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 90aabf45-884d-49e8-b7ab-ed5bf8836182
⛔ Files ignored due to path filters (2)
example/ios/Podfile.lockis excluded by!**/*.lockyarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (17)
A0Auth0.podspecEXAMPLES.mdREADME.mdandroid/src/main/java/com/auth0/react/A0Auth0Module.ktandroid/src/main/java/com/auth0/react/CredentialsParser.ktios/NativeBridge.swiftpackage.jsonsrc/core/models/Credentials.tssrc/core/models/CredentialsManagerError.tssrc/core/models/__tests__/Credentials.spec.tssrc/core/models/__tests__/ErrorCodes.spec.tssrc/platforms/native/adapters/__tests__/NativeCredentialsManager.errors.spec.tssrc/platforms/native/adapters/__tests__/NativeCredentialsManager.spec.tssrc/platforms/web/adapters/WebCredentialsManager.tssrc/platforms/web/adapters/__tests__/WebCredentialsManager.errors.spec.tssrc/platforms/web/adapters/__tests__/WebCredentialsManager.spec.tssrc/types/common.ts
Adds support for the IPSIE SL1
session_expiryclaim. When an enterprise connection sets an upstream session ceiling, Auth0 stamps asession_expirytimestamp into the ID token, and the underlying platform SDKs enforce it as a hard ceiling on every credential retrieval — past the ceiling the stored credentials are cleared and refresh is skipped, so the user must re-authenticate.it surfaces this outcome as a single, platform-agnostic
CredentialsManagerErrorwithtype === 'SESSION_EXPIRED'across iOS, Android, and Web.Credentials also expose an optional
sessionExpiresAt(Unix seconds), surfaced for display only — enforcement stays in the platform SDKs. On iOS and Web it is decoded from the current ID token'ssession_expiryclaim; on Android it reflects the ceiling pinned at initial login (the value the credentials manager actually enforces). It isundefinedwhen the connection does not emit the claim.Summary by CodeRabbit
session_expiryclaim.sessionExpiresAton returned credentials.SESSION_EXPIREDerror type that indicates re-authentication is required.session_expiryand propagatingSESSION_EXPIRED.