Repository navigation
fix(social-login): resume /authorize on Authorizer's login page (authorizer#855) - #75
Merged
Merged
Conversation
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).
size-limit report 📦
|
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
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.
Client side of authorizerdev/authorizer#855. Server side: authorizerdev/authorizer#899. Docs: authorizerdev/docs#98.
Problem
When
/authorizeneeds a sign-in it opens Authorizer's login page (/app/?client_id=…&response_type=…&redirect_uri=<client callback>&…).AuthorizerSocialLoginforwarded that client callback to/oauth_login/<provider>asredirect_uri. As a result:--allowed-originsgot400 invalid redirect uri;Fix
On Authorizer's own login page during an
/authorizerequest, the buttons send the page's own URL asredirect_uri, with the/authorizeparameters in the query string. After the provider, the user comes back to/app.Rootthen replays the request to/authorize, which checks the client's registered callback, runs consent and binds PKCE: the same path password login already takes.redirectURLis dropped in that case, because the server reads it beforeredirect_uri.getAuthorizeResumeURL(src/utils/authorizeResume.ts) returns a URL only when all of these hold. Otherwise it returnsnulland nothing changes:authorizerURL's origin, i.e. Authorizer is serving the page (the hostedweb/appsetsauthorizerURL: window.location.origin);/app,/app/or/app/signup./app/is where a browser actually is, because Authorizer 301s/appto it;client_idandresponse_type.Fragment parameters (
response_mode=fragment) move into the query string; query values win, as inRoot.Compatibility
authorizerURL./appwith no/authorizerequest: unchanged.Tests
authorizeResume.test.ts(15 tests):/app/,/app/signup;nullfor your own site, another port, another scheme, another path,/app/signup/, no/authorizerequest, missingclient_idorresponse_type, and a badauthorizerURL.AuthorizerSocialLogin.test.tsx(4 tests): renders the component, clicks GitHub, and asserts the exact/oauth_loginURL:/app/during/authorizeit sends the/app/URL and noredirectURL;response_mode=fragmentmoves into the query;redirect_uriis kept;/appkeeps the default.e2e-playground). A self-registered client outside--allowed-originscompletes GitHub login, consent comes before anything reaches the client, the code redeems, and the ID token carries the client'snonce. That run is what found the/app/case.npm test(24 passed),npm run type-checkandnpm run buildall pass. Prettier is applied to the changed files.Lint fixed (4f68300):
npm run lintused to check nothing.eslint.config.jswas written in the legacy.eslintrcshape, so ESLint 9 matched no files, and this was also true onmain. 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/jsandglobalsare now direct devDependencies (before, they were only installed indirectly through other packages). Thelintscript drops the unsupported--extflag and still runs--fix. All 63srcfiles are now linted, with 0 errors and 56 warnings.@typescript-eslint/no-explicit-anyis set to warn because there are about 40 existinganys. The other 15 warnings arereact-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,Functionreplaced by a typed setter,const, an unused catch binding, a named Storybook decorator, regex escapes that did nothing, and a@ts-ignorethat wasn't needed.Release order
@authorizerdev/authorizer-reactin authorizerweb/app, adding the Playwright spec, before Authorizer 2.4.6.