Skip to content

fix(social-login): resume /authorize on Authorizer's login page (authorizer#855) - #75

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

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

Conversation

@lakhansamani

@lakhansamani lakhansamani commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Client side of authorizerdev/authorizer#855. Server side: authorizerdev/authorizer#899. Docs: authorizerdev/docs#98.

Problem

When /authorize needs a sign-in it opens Authorizer's login page (/app/?client_id=…&response_type=…&redirect_uri=<client callback>&…). AuthorizerSocialLogin forwarded that client callback to /oauth_login/<provider> as redirect_uri. As a result:

  • a client whose callback isn't in the server's --allowed-origins got 400 invalid redirect uri;
  • when it was allowed, the code went straight to the client, skipping the consent screen for self-registered clients.

Fix

On Authorizer's own login page during an /authorize request, the buttons send the page's own URL as redirect_uri, with the /authorize parameters in the query string. After the provider, the user comes back to /app. Root then replays the request to /authorize, which checks the client's registered callback, runs consent and binds PKCE: the same path password login already takes. redirectURL is dropped in that case, because the server reads it before redirect_uri.

getAuthorizeResumeURL (src/utils/authorizeResume.ts) returns a URL only when all of these hold. Otherwise it returns null and nothing changes:

  • the page's origin equals authorizerURL's origin, i.e. Authorizer is serving the page (the hosted web/app sets authorizerURL: window.location.origin);
  • the path is exactly /app, /app/ or /app/signup. /app/ is where a browser actually is, because Authorizer 301s /app to it;
  • the URL carries both client_id and response_type.

Fragment parameters (response_mode=fragment) move into the query string; query values win, as in Root.

Compatibility

Tests

  • authorizeResume.test.ts (15 tests):
    • the URL with every parameter;
    • /app/, /app/signup;
    • fragment-to-query, and query winning over fragment;
    • null for your own site, another port, another scheme, another path, /app/signup/, no /authorize request, missing client_id or response_type, and a bad authorizerURL.
  • AuthorizerSocialLogin.test.tsx (4 tests): renders the component, clicks GitHub, and asserts the exact /oauth_login URL:
    • on /app/ during /authorize it sends the /app/ URL and no redirectURL;
    • response_mode=fragment moves into the query;
    • on your own site, the caller's redirect_uri is kept;
    • plain /app keeps the default.
  • The tests fail without the fix: on the original component, the two resume tests fail and the two unchanged-behaviour tests pass.
  • Real browser: built into Authorizer's image alongside fix(oauth): resume social login through /authorize (#855) authorizer#899 and driven with Playwright (e2e-playground). A self-registered client outside --allowed-origins completes GitHub login, consent comes before anything reaches the client, the code redeems, and the ID token carries the client's nonce. That run is what found the /app/ case.

npm test (24 passed), npm run type-check and npm run build all pass. Prettier is applied to the changed files.

Lint fixed (4f68300): npm run lint used to check nothing. eslint.config.js was written in the legacy .eslintrc shape, so ESLint 9 matched no files, and this was also true on main. The config is now a flat config with the same intent: eslint:recommended, @typescript-eslint recommended, react and react-hooks recommended, the same rule overrides, browser/es2021/node globals and React version detect. @eslint/js and globals are now direct devDependencies (before, they were only installed indirectly through other packages). The lint script drops the unsupported --ext flag and still runs --fix. All 63 src files are now linted, with 0 errors and 56 warnings. @typescript-eslint/no-explicit-any is set to warn because there are about 40 existing anys. The other 15 warnings are react-hooks/exhaustive-deps, which is already a warning in the recommended config. The 9 other findings were fixed in source with minimal, behaviour-preserving changes: escaped apostrophes, Function replaced by a typed setter, const, an unused catch binding, a named Storybook decorator, regex escapes that did nothing, and a @ts-ignore that wasn't needed.

Release order

  1. Merge fix(oauth): resume social login through /authorize (#855) authorizer#899.
  2. Release this as 2.2.1. The changelog entry is under Unreleased, and the docs refer to 2.2.1.
  3. Bump @authorizerdev/authorizer-react in authorizer web/app, adding the Playwright spec, before Authorizer 2.4.6.
  4. Publish docs: social login resumes through /authorize (2.4.6) docs#98.

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).
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
dist/index.cjs 60.96 KB (+0.27% 🔺)
dist/index.mjs 60.6 KB (+0.12% 🔺)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant