fix: route the OIDC callback deep link instead of 404ing on it - #51
Open
alexandre-vl wants to merge 1 commit into
Open
fix: route the OIDC callback deep link instead of 404ing on it#51alexandre-vl wants to merge 1 commit into
alexandre-vl wants to merge 1 commit into
Conversation
`termix-mobile://oidc-callback` is normally captured by WebBrowser.openAuthSessionAsync and never reaches the router. When Android delivers it as a plain intent instead — a Custom Tab handing the redirect to the OS, or a cold start — expo-router resolves it as the path "/oidc-callback", finds no matching file and renders Unmatched Route, at the end of a sign-in the server considered successful. Three changes, one per way the link can arrive: - app/oidc-callback.tsx gives the path a route, so an OS-delivered link lands in the app rather than on the 404 screen, and redirects on to the tabs. - The WebView now intercepts termix-mobile:// navigations through onShouldStartLoadWithRequest. A server that was handed an appCallbackUrl answers the OIDC callback with that redirect rather than the postMessage handoff the embedded login expects, and Android would otherwise fire it at the OS as an intent. - OidcStep drains a link parked by the route before wiping the stored jwt, so a callback that arrived before the sign-in screen existed completes instead of being discarded and sending the user back to the IdP. The parked link and the already-handled check live in app/utils/oidc-callback.ts. Both paths can see the same intent, so it is claimed once — a duplicate confirmation that failed would clear the JWT the first one had just stored. The callback URL carries a bearer token, so nothing is retained: the parked value is cleared when consumed and the handled check compares fingerprints.
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.
Overview
termix-mobile://oidc-callbackhas no route. When Android delivers it as a plain intent rather than throughWebBrowser.openAuthSessionAsync, expo-router resolves the path/oidc-callback, finds nothing and renders Unmatched Route — Page could not be found, at the end of a sign-in the server already logged as successful.app/oidc-callback.tsxroute andapp/utils/oidc-callback.tshand-offtermix-mobile://redirect escaping the embedded WebView to the OSChanges Made
Three changes, one per way the link can arrive:
app/oidc-callback.tsx— gives the path a real route, so an OS-delivered link lands in the app instead of the 404 screen, then redirects on to the tabs. The URL is rebuilt fromuseLocalSearchParamsrather than read back fromLinking, so nothing depends on Hermes parsing a custom scheme. It is parked during render, not in an effect:<Redirect>navigates from its own effect and child effects flush before the parent's.AuthFlow.tsx, WebView —onShouldStartLoadWithRequestnow interceptstermix-mobile://navigations. A server that was handed anappCallbackUrlanswers/users/oidc/callbackwith that redirect rather than thepostMessagehandoff the embedded login expects, and Android would otherwise fire it at the OS as an intent.AuthFlow.tsx,OidcStepinit — drains a link parked by the route beforeAsyncStorage.removeItem("jwt"), so a callback that arrived before the sign-in screen existed completes rather than being discarded and sending the user back to the IdP.app/utils/oidc-callback.tsholds the parked link and the already-handled check. Both paths can see the same intent, so it is claimed once — a duplicate confirmation that failed would clear the JWT the first one had just stored. The callback URL carries a bearer token, so nothing is retained: the parked value is cleared when consumed, and the handled check compares fingerprints rather than URLs, over a bounded list.Related Issues
Screenshots / Demos
Verified statically only — I have no Android device or emulator to exercise the flow on, so the runtime behaviour of
onShouldStartLoadWithRequestagainst a custom-scheme navigation has not been confirmed on a build.Checklist