Repository navigation
fix: preserve OIDC deep links across callback storage #306
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
Changes from 4 commits
09a9ca1
f7d11e3
e0dbc38
f922322
fc7969e
2d7f899
3a32312
d8b7eef
4e40e26
dab3994
b478f32
5c42aa2
bcd17a4
a5ca5c3
2e0698f
1e7eb26
08d7f95
dd9c3a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # ADR 0109: Recover authenticated deep links across OIDC callback contexts | ||
|
|
||
| - Status: Accepted | ||
| - Date: 2026-08-20 | ||
| - Depends on: [0069](0069-member-locale-preference.md), [0028](0028-keyverse-oidc-provider.md) | ||
|
|
||
| ## Context | ||
|
|
||
| The Buyer can be opened directly at `/?post=<id>`. The OIDC provider callback | ||
| may omit application state or complete in a browser context where the original | ||
| tab's `sessionStorage` is not available. Falling back to `/` loses the post | ||
| deep link and presents the unauthenticated language/login surface again, even | ||
| when the member's OIDC session is otherwise valid. | ||
|
|
||
| ## Decision | ||
|
|
||
| - Keep the OIDC `state.returnUrl` as the first recovery source. | ||
| - Persist the same validated same-origin path in both `sessionStorage` and | ||
| `localStorage` before redirecting to OIDC. `localStorage` is only a bounded | ||
| recovery fallback, not an authentication or authorization store. | ||
| - On callback, remove the key from both stores and use session storage before | ||
| local storage. Reject external and protocol-relative URLs. | ||
| - Keep member language preference account-scoped in | ||
| `user_account.preferred_locale`; this ADR does not move locale state into the | ||
| post URL, browser storage, or a `user_account + post_id` key. | ||
|
|
||
| ## Consequences | ||
|
|
||
| Opening a shared post link survives a missing OIDC state payload or a changed | ||
| storage context without losing the post. A stale internal return path is | ||
| removed at callback, and authorization still comes only from the authenticated | ||
| OIDC token and backend ABAC checks. |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Single-JSON-encoded safe string is now rejected (behavior change) The previous recursive implementation would accept a state that was a JSON-encoded plain string of a safe path (e.g. state = '"/?post=x"'): it parsed once to the string, recursed, failed the second parse, and returned the safe path. The new single-parse implementation (oidcReturnUrl.ts) parses once, gets a string, then fails the (Refers to this code) Was this helpful? React with 👍 or 👎 to provide feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: localStorage fallback staleness is bounded and acceptable The new (Refers to this code) Was this helpful? React with 👍 or 👎 to provide feedback. |
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.
📝 Info: Shared localStorage key can recover the wrong deep link across concurrent logins
rememberOidcReturnUrlnow also writes the return path towindow.localStorageunder a single fixed keylineageweave.oidc.returnUrl(oidcReturnUrl.ts), andrestoreOidcReturnUrlfalls back to it (oidcReturnUrl.ts). localStorage is shared across all tabs of the origin, so if a user initiates login from tab A at/?post=Aand then from tab B at/?post=B, tab B overwrites the shared key. If tab A's OIDC callback completes in a context where its per-tab sessionStorage is unavailable (exactly the cross-context recovery scenario this PR targets), it will read/?post=Bfrom localStorage and recover the wrong post. Session storage is preferred first (:74) which mitigates the common same-tab case, and the more reliable sourcestate.returnUrlis preferred over both, so impact is limited to the concurrent-login-with-lost-session edge case. Not flagged as a bug because it is an inherent tradeoff of a single-key shared store and the primary recovery path (OIDC state) is unaffected, but worth confirming this edge case is acceptable.(Refers to this code)
Was this helpful? React with 👍 or 👎 to provide feedback.