fix(web): stop rewriting the OAuth state so Google login works again - #1187
Merged
Merged
Conversation
The enclave issues the OAuth `state` as base64url JSON without padding and rejects any returned state that does not decode with a no-padding decoder and match its stored copy. initiateGoogleAuth decoded that state, added a sessionId for the deep-link stash, and re-encoded it with @stablelib/base64, which pads with `=`. That only worked while the rewritten JSON happened to be a multiple of 3 bytes; since the enclave added `redirect_url` to the state on 2026-09-21 every Google login fails with 400 Bad Request. Return the auth URL untouched and key the sessionStorage stash by the SHA-256 of the verbatim state instead. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
jbojcic1
approved these changes
Sep 25, 2026
This branch was successfully deployed
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.
Cherry-pick of #1186 (commit 0911d33) onto
livefor prod. The only adaptation is the pre-SDKosInitiateGoogleAuthcall inauth.ts.Problem
Google login and signup fail on next.agi.cash and agi.cash with
400 Bad Requestfrom the Open Secret enclave at/auth/google/callback(shown as "Failed to authenticate with Google. Please try again.").initiateGoogleAuthdecoded the enclave's OAuthstate(base64url JSON, no padding), added asessionIdso the callback route could restore the deep link, and re-encoded it with@stablelib/base64, which pads with=. The enclave decodes the returned state with a strict no-padding decoder and then compares it with its stored copy, so any=fails the login.This worked by accident: the rewritten JSON was 141 bytes (a multiple of 3), so no padding was ever emitted. On 2026-09-21 the enclave started to include
redirect_urlin the state (Maple repo,services/opensecret/docs/oauth-callbacks.md, which also says clients must return the state unchanged). The rewritten JSON became 193 bytes, the encoder added=, and every Google login broke.Verified live against the enclave with a bogus code: the unchanged state and the rewritten state without padding both pass the state check (and fail later at Google with 500), while the app's actual rewritten state gets
400 Bad Request.Fix
state(the value Google echoes back) instead of a generated session id threaded through the state.statefrom the URL.Notes
@stablelib/base64is no longer used byweb-wallet(the SDK and e2e still use it). The dependency entry can go in a follow-up.livein a separate PR (cherry-pick).Test plan
bun run fix:all,bun run typecheckoauth-login-session-storage.test.ts/login?redirectTo=...with a token hash)🤖 Generated with Claude Code