Skip to content

feat(content-server,settings): serve React for oauth/success route - #21247

Open
vbudhram wants to merge 1 commit into
mainfrom
fxa-6642
Open

vbudhram wants to merge 1 commit into
mainfrom
fxa-6642

Conversation

@vbudhram

@vbudhram vbudhram commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Because

  • A hard load of /oauth/success/:client_id was still served by Backbone.
  • The React page needs the client id, but that URL has no query parameters.

This pull request

  • Adds an oauthSuccessRoutes group in server/lib/routes/react-app/index.js, so Express sends the route to React. The group is hardcoded on, because Backbone no longer serves the route.
  • Removes the oauth/success/:client_id entry from app/scripts/lib/router.js. views/ready.js stays, because six other Backbone routes use it.
  • Adds getOAuthSuccessClientId in src/lib/oauth/success-route.ts. The integration factory, useClientInfoState, and OAuthWebIntegration read the client id from the pathname. The helper also accepts a trailing slash.
  • Sets isOAuthSuccessFlow on OAuthWebIntegration. An empty scope now gives an empty permission list instead of an error.
  • Renames getRoutesExcludingOAuthSuccessReact to getBackboneOAuthSuccessRouteNames in get-oauth-success.js, from review feedback. The old name described an exclusion, not the route names it returns. No behaviour change.

Issue that this pull request solves

Closes: FXA-6642

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on: react-app/index.js, get-oauth-success.js, success-route.ts.
  • Suggested review order: the Express route group, then the Backbone router removal, then the client id lookup in fxa-settings.
  • Risky or complex parts: the router removal changes which app serves the URL. views/ready.js must stay for the other Backbone routes.

Screenshots (Optional)

None. The page renders the same React screen as before.

Other information (Optional)

  • The four fxa-settings suites this branch touches pass locally: 101 tests, 0 failures.
  • npx eslint app server in packages/fxa-content-server: exit 0.
  • npx nx lint fxa-content-server did not finish. Its lint-glean step builds a Python venv and the sandbox has no network. The eslint half ran directly, as shown above.
  • An inline node check of getBackboneOAuthSuccessRouteNames and the default export: 5 passed, 0 failed. No test file was added. fxa-content-server has only tests/functional and no unit test target.
  • The functional tests did not run in the sandbox. CI covers them.
  • get-frontend.js and get-frontend-pairing.js keep the older getRoutesExcluding* names. This pull request does not touch them.

@vbudhram vbudhram added the auto label Sep 17, 2026
Copilot AI balanced review requested due to automatic review settings September 17, 2026 19:35
@vbudhram vbudhram added the auto label Sep 17, 2026
@vbudhram
vbudhram requested a review from a team September 17, 2026 19:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Pathname-only hard loads still trigger the client-info error guard before PairSuccess renders.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Migrates /oauth/success/:clientId from Backbone to the React PairSuccess flow.

Changes:

  • Adds an unconditional React route group and removes the Backbone route.
  • Handles scope-less OAuth success integrations.
  • Adds trailing-slash and integration tests.
File summaries
File Description
oauth-web-integration.ts Bypasses permission parsing for success flows.
oauth-web-integration.test.ts Tests empty permissions.
integration-factory.ts Marks success-flow integrations.
integration-factory.test.ts Tests factory behavior.
integration-factory-flags.ts Extracts client IDs with trailing slashes.
integration-factory-flags.test.ts Tests trailing-slash parsing.
react-app/index.js Adds the React route group.
get-oauth-success.js Disables the server Backbone fallback.
router.js Removes the client Backbone route.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

throw new OAuthError('INVALID_PARAMETER');
}
integration.data.clientId = clientId;
integration.isOAuthSuccessFlow = true;

@LZoog LZoog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably update that one function name and can we add a Storybook page for this in React? Otherwise just want to spot check locally and can r+


function getRoutesExcludingOAuthSuccessReact({ oauthRoutes }, routeNames) {
return oauthRoutes.featureFlagOn
function getRoutesExcludingOAuthSuccessReact(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is named getRoutesExcludingOAuthSuccessReact but is now getting oauthSuccessRoutes? Should this be updated to just getOAuthRoutes?

}>({ loading: true });

const urlQueryData = new UrlQueryData(new ReachRouterWindow());
// A hard load of `/oauth/success/:clientId` carries no query params.

@LZoog LZoog Sep 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Fine to ignore)
Was going to leave a nit about removing the comment but I guess even though the client ID is always in the URL, it probably had it as a query param at some point? So ehh I guess we can leave this comment (just thinking out loud)

}
);
},
'oauth/success/:client_id(/)': createViewHandler(ReadyView, {

@LZoog LZoog Sep 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Fine to ignore)

We've been saving these for the removal issues but I see this:

Removes the oauth/success/:client_id(/) entry from app/scripts/lib/router.js. The views/ready.js import stays, because other routes still use it.

So 👍 seems fine

## Because

- A hard load of `/oauth/success/:client_id` was still served by Backbone.
- The React page needs the client id, but that URL has no query parameters.

## This pull request

- Adds an `oauthSuccessRoutes` group in `server/lib/routes/react-app/index.js`, so Express sends the route to React. The group is hardcoded on, because Backbone no longer serves the route.
- Removes the `oauth/success/:client_id` entry from `app/scripts/lib/router.js`. `views/ready.js` stays, because six other Backbone routes use it.
- Adds `getOAuthSuccessClientId` in `src/lib/oauth/success-route.ts`. The integration factory, `useClientInfoState`, and `OAuthWebIntegration` read the client id from the pathname. The helper also accepts a trailing slash.
- Sets `isOAuthSuccessFlow` on `OAuthWebIntegration`. An empty scope now gives an empty permission list instead of an error.
- Renames `getRoutesExcludingOAuthSuccessReact` to `getBackboneOAuthSuccessRouteNames` in `get-oauth-success.js`, from review feedback. The old name described an exclusion, not the route names it returns. No behaviour change.

## Issue that this pull request solves

Closes: FXA-6642
@vbudhram
vbudhram requested review from a team and a balanced review from Copilot September 21, 2026 16:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The routing migration and pathname-based client lookup are consistent and covered by focused tests.

Review effort: Balanced
Findings: 1 High severity

Open (1)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants