Skip to content

fix(oauth): resume social login through /authorize (#855) - #899

Merged
lakhansamani merged 3 commits into
mainfrom
fix/855-social-login-authorize-resume
Nov 17, 2026
Merged

lakhansamani merged 3 commits into
mainfrom
fix/855-social-login-authorize-resume

Conversation

@lakhansamani

@lakhansamani lakhansamani commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #855. Docs: authorizerdev/docs#98.

Problem

/oauth_login and /oauth_callback checked redirect_uri only against the global --allowed-origins, and on an /authorize-originated login they minted the authorization code themselves and sent it straight to the client. That caused two problems:

  1. /oauth_login and /oauth_callback ignore a client's registered redirect_uris (social login fails with "invalid redirect uri" for clients on other origins) #855: a client whose registered callback is on another origin passed /authorize and /app, then got 400 invalid redirect uri at social login. The only workaround was adding the client's origin to --allowed-origins, which also loosens CORS, the CSRF origin check and every token-carrying redirect, for every client.
  2. Consent skipped: the consent gate for self-registered (DCR) and CIMD clients lives only in /authorize (authorize.go:701). Social login bypassed it. Today only the allowed-origins check prevents a self-registered client from getting a consent-free code through social login, so simply letting /oauth_login accept the client's registered callbacks would have opened account takeover.

Fix

Social login now ends the same way password login already does (web/app/src/Root.tsx): it returns to this server's /app, which replays the original request to /authorize. /authorize then validates the client's registered redirect_uri, runs consent and PKCE, and issues the code. This is Auth0's model too: social login is part of the /authorize transaction, the provider returns to the server's own callback, and only /authorize redirects to the app's registered callback.

  • isAuthorizeResumeTarget: /oauth_login and /oauth_callback also accept this server's own /app, /app/ or /app/signup. /app/ is the URL a browser is actually on: /authorize redirects to /app, and the /app route group 301s that to /app/. That means the same scheme and host:port (from --url), the exact path, and no userinfo or fragment. Nothing else is loosened: client origins are still not accepted here.
  • Callback on the resume hop: it sets the session cookie only. It mints no code (the resumed /authorize issues one after consent), and it redirects to the /app URL unchanged. Appending state/nonce would let /app forward the callback's random nonce instead of the client's.
  • Old direct path: unchanged, but it logs a deprecation warning when it completes an /authorize request. A later release will refuse it.

No API, schema, proto or storage changes.

Backward compatibility

  • Login UIs on the current @authorizerdev/authorizer-react keep sending the client callback directly, and that path behaves exactly as before. The only addition is the warning when it completes an /authorize request.
  • No capability flag. /authorize only ever sends users to this server's own /app, and that page is built into the same image as the server. So the login UI that uses the resume path can never run against a server without it. Compatibility is documented in docs: social login resumes through /authorize (2.4.6) docs#98 instead.
  • One behaviour change for default deployments: social login started directly on /app, with no /authorize request, used to return to /app?state=…&nonce=…, and only under a bare *. It now returns to /app unchanged, under any --allowed-origins list. Nothing on /app reads either parameter (checked in Root.tsx and the authorizer-react bundle), and there's a subtest for it.
  • Checked during review:
    • prompt/max_age aren't forwarded to /app, so a resumed request can't force re-login in a loop.
    • The MFA-withheld redirect still appends only the mfa_* parameters.
    • With --url unset (tests and library embedders only), spoofing the host header affects only the sender's own request; the callback re-checks the host from the real browser request.

Tests

Verification (local, go1.27.4)

  • Real browser (e2e-playground, Playwright): with this branch and the matching authorizer-react change built into the image, a self-registered client whose callback is outside --allowed-origins completes GitHub login. The button sends the /app/ URL, the user sees consent before anything reaches the client, and the code redeems with the client's nonce. This run is what found the /app/ case, which every Go test had missed by using /app. The spec lands with the PR that bumps authorizer-react in web/app, since it needs that change to pass.

  • go build ./..., go vet ./...

  • make lint (golangci-lint 0 issues, prettier clean)

  • buf lint, make proto-breaking

  • make test passes; make smoke passes (GraphQL + REST + gRPC + MCP)

Follow-ups

  • @authorizerdev/authorizer-react: when the page is served from the Authorizer origin and its URL carries /authorize parameters, the social buttons send redirect_uri = the current /app?… URL, with the parameters in the query string. Bump it in web/app before 2.4.6, which docs: social login resumes through /authorize (2.4.6) docs#98 assumes.
  • Enforce: refuse an /authorize-originated social login that targets anything other than /app, behind an upgrade note.
  • Audit oauth_sso.go and saml_sp.go, which also consume the /authorize state and may deliver the code the same direct way.

/oauth_login and /oauth_callback held redirect_uri to --allowed-origins and
delivered the authorization code themselves, so a client whose registered
callback is on another origin could not use social login, and an
/authorize-originated social login skipped the consent gate.

Social login may now return to this server's own /app (exact path, same
scheme and host:port), which replays the request to /authorize — the same
resumption password login already uses. On that hop the callback sets the
session only: no code is minted and nothing is appended, so the client's
nonce survives into the id_token.

- meta: is_social_login_authorize_resume_supported (GraphQL + gRPC) so login
  UIs adopt the resume path only against a server that supports it
- the old direct path is unchanged but logs a deprecation warning when it
  completes an /authorize request; a later release refuses it
is_social_login_authorize_resume_supported protected nothing: /authorize
only ever sends users to this server's own /app, and that login page is
built into the same image as the server, so it cannot run against a server
that lacks the resume path. Compatibility is documented instead
(authorizerdev/docs#98). Schema, proto and generated code are back to main.

Adds a subtest for social login started on /app with no /authorize request,
the one behaviour this change alters for default deployments: it now returns
to /app without state/nonce appended, which nothing on /app reads.
/authorize redirects to /app and the /app route group 301s that to /app/,
so a browser renders the login page at /app/?... and that is the URL the
login page sends back as redirect_uri. Requiring exactly /app refused it.
Found by driving the flow in a real browser (e2e-playground); every Go test
had used /app.

/app/signup has no such redirect (its trailing-slash form 301s to it), so
the accepted set is /app, /app/ and /app/signup.
@lakhansamani
lakhansamani merged commit 3db004e into main Nov 17, 2026
4 checks passed
@lakhansamani
lakhansamani deleted the fix/855-social-login-authorize-resume branch November 17, 2026 07:21
lakhansamani added a commit to authorizerdev/authorizer-react that referenced this pull request Nov 17, 2026
…orizer#855) (#75)

* fix(social-login): resume /authorize on Authorizer's login page

When /authorize opens Authorizer's login page (/app, /app/ or /app/signup),
AuthorizerSocialLogin now sends that page's own URL as redirect_uri, with
the /authorize parameters in the query string, instead of the client's
callback. The login comes back to /app, which replays the request to
/authorize: the client's registered redirect_uri is checked, consent runs,
and PKCE is bound. Fixes authorizerdev/authorizer#855.

Applies only when the page's origin equals authorizerURL and its URL has
client_id and response_type; everywhere else the redirect_uri is unchanged.
Requires Authorizer 2.4.6+ (authorizerdev/authorizer#899).

* chore(lint): migrate ESLint to flat config so lint runs

eslint.config.js used the legacy .eslintrc object shape, which ESLint 9
treats as a flat config with no file matches, so 'npm run lint' ignored
every file. Rewrite it as a flat config with the same intent
(eslint:recommended, @typescript-eslint recommended, react recommended,
react-hooks recommended, same rule overrides, browser/es2021/node
globals, React version detect).

- add @eslint/js and globals as direct devDependencies (were only
  transitive; globals was hoisted at v11)
- drop the unsupported --ext flag from the lint script
- set @typescript-eslint/no-explicit-any to warn (~40 pre-existing anys)
- fix the remaining findings: unescaped apostrophes, Function type,
  prefer-const, unused catch binding, decorator display name, useless
  regex escapes, unnecessary @ts-ignore
lakhansamani added a commit to authorizerdev/docs that referenced this pull request Nov 17, 2026
* docs: social login resumes through /authorize (2.4.6)

Documents authorizerdev/authorizer#899 (fixes authorizerdev/authorizer#855):
how social login inside an /authorize request now returns to /app and
resumes through /authorize, what /oauth_login accepts as redirect_uri, what
the callback appends, the compatibility matrix for hosted, custom and direct
login UIs, the deprecated direct path and its log warning, and two Common
Issues rows. Also documents redirect_uri on /oauth_login (redirectURL is the
deprecated alias) and fixes the sample's role= to roles=.

* docs: worked examples for social login inside /authorize

- oauth2-oidc: redirect_uri acceptance table, a full hop-by-hop round trip
  (including the /app -> /app/ redirect), a plain-JS customised login page,
  a before/after for older login pages, and a browser test step in the
  Testing Guide
- authorizer-react: where AuthorizerSocialLogin returns the user, with
  examples for your own site, a per-screen landing page, and Authorizer's
  login page during /authorize (2.2.1+, Authorizer 2.4.6+)
- endpoints: sample URLs for both /oauth_login forms
- the login page's real path is /app/ (Authorizer 301s /app), so the
  accepted set is /app, /app/ and /app/signup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant