Skip to content

MPDX-10415 Remove the API_OAUTH sign-in provider - #2323

Open
jbirdjavi wants to merge 2 commits into
mainfrom
MPDX-10415
Open

jbirdjavi wants to merge 2 commits into
mainfrom
MPDX-10415

Conversation

@jbirdjavi

Copy link
Copy Markdown
Contributor

Links

Description

The API is removing api_oauth sign-in and the apiOauthSignIn GraphQL mutation in CruGlobal/mpdx_api#3844. That makes this app's AUTH_PROVIDER=API_OAUTH option dead, so this PR removes it. Okta sign-in does not change.

  • pages/api/auth/[...nextauth].page.ts: drop the apioauth provider, its API_OAUTH_* env checks, and the apiOauthSignIn call in the sign-in callback. The AUTH_PROVIDER startup guard now accepts only OKTA. The Okta provider, its env guard, the oktaSignIn path, and the JWT and session callbacks are unchanged.
  • Delete pages/api/auth/apiOauthSignIn.ts, the hand-committed generated file for the removed mutation.
  • next.config.ts: drop the API_OAUTH_* env defaults and the API_OAUTH_CLIENT_SECRET line in the secrets block. JWT_SECRET, OKTA_CLIENT_SECRET and ROLLBAR_SERVER_ACCESS_TOKEN still parse as before.
  • pages/login.page.tsx: the button always reads "Sign In", which is what Okta users already saw. The "Sign In with SSO" text is gone.
  • README and CLAUDE.md: Okta is now the only provider.
  • Tests: delete pages/login-apioauth.page.test.tsx. Add pages/api/auth/[...nextauth].page.test.ts, which checks that the route loads with OKTA and throws on any other AUTH_PROVIDER value or a missing OKTA_* variable. Both kinds of case fail with main's guards put back. pages/login.page.test.tsx now matches the button name "Sign In" exactly. The old /sign in/i also matched "Sign In with SSO".

Why it is safe: the API saw no api_oauth or apiOauthSignIn sign-ins in about 7 days of prod logs, and AUTH_PROVIDER defaults to OKTA in next.config.ts.

Depends on: none. This can merge before or after CruGlobal/mpdx_api#3844. The API_OAUTH path already needs an API-side OAuth app, and prod and stage have none for it.

Not in this PR: .claude/review/rules/security.md and api-contracts.md still describe the API_OAUTH provider. Review rules change in their own PR. scripts/jest-shards/timings.json keeps its entry for the deleted test until the next timings refresh.

Testing

  • Sign in on the preview environment with Okta and check that the dashboard loads.
  • On the login page, check that the button reads "Sign In".
  • Sign out and sign back in once more.

AI review

Findings I did not fix, and why:

Checklist:

  • My PR title is the work item key, then a summary of 80 characters or less (example: MPDX-1234 Add sortable columns)
  • I have applied the appropriate labels (Add the label "Preview Environment" to automatically create a preview environment)
  • I have run the Claude Code /agent-review:review command locally and fixed each finding or listed it above
  • The github-actions bot has approved the PR (it approves once /agent-review:review leaves no open blockers; it never approves a one-way door)
  • I have asked a person to review, if this is a one-way door (it touches a path .github/CODEOWNERS gives an owner)
  • I have tested my changes in preview or in staging
  • I have cleaned up my commit history

🤖 Generated with Claude Code

The API is removing the apiOauthSignIn mutation and api_oauth sign-in
(CruGlobal/mpdx_api#3844), so this provider can no longer sign anyone
in. The API saw no api_oauth or apiOauthSignIn sign-ins in about a week
of prod logs, and every environment signs in with Okta.

- Drop the apioauth next-auth provider, its env checks and its
  apiOauthSignIn call, and the hand-committed apiOauthSignIn.ts.
- AUTH_PROVIDER must now be OKTA; anything else still fails at startup.
- Drop the API_OAUTH_* env defaults and secret from next.config.ts, the
  "Sign In with SSO" button text, and the README and CLAUDE.md docs.
- Delete the API_OAUTH login test, add a test for the auth route's
  startup guards, and pin the Okta button text exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jbirdjavi jbirdjavi added the Preview Environment Add this label to create an Amplify Preview label Nov 30, 2026
@jbirdjavi jbirdjavi self-assigned this Nov 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Preview branch generated at https://MPDX-10415.d3dytjb8adxkk5.amplifyapp.com

@github-actions

Copy link
Copy Markdown
Contributor

Bundle sizes [mpdx-react]

Compared against c8a4738

No significant changes found

@jbirdjavi

jbirdjavi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 agent-review · ✅ no blockers · risk CRITICAL · 👤 needs a person
Rollout: advisory · 5 agents run (Code Review (/code-review xhigh), Security Review Agent, Testing & Quality Review Agent, Standards Compliance Review Agent, UX & Accessibility Review Agent) · incremental since a03431b

BLOCKERS: fix or dismiss to pass

✅ No blockers.

👤 Needs a person's approval: PCI path: CLAUDE.md; PCI path: next.config.ts; PCI path: pages/api/auth/[...nextauth].page.test.ts; PCI path: pages/api/auth/[...nextauth].page.ts; PCI path: pages/api/auth/apiOauthSignIn.ts. The bot will not approve this PR.

OTHER FINDINGS (14)

  • #1 · 6/10 · pages/login.page.tsx:124 · getServerSideProps redirects a signed-in user to the raw ?redirect= query value, so /login?redirect=https://evil.example is an open redirect. The code is unchanged by this PR. (code-review)
  • #6 · 6/10 · pages/api/auth/[...nextauth].page.ts:190 · The NextAuth redirect callback is an open redirect: url.startsWith(baseUrl) accepts look-alike hosts such as https://mpdx.org.evil.com, and new URL("//evil.com/x", baseUrl) resolves to https://evil.com/x. A crafted callbackUrl sends the user to an outside site right after a real Okta sign-in. (code-review)
  • #2 · 5/10 · pages/api/auth/[...nextauth].page.ts:59 · The guard now throws at module load for AUTH_PROVIDER=API_OAUTH, so any deploy still built with that value 500s every /api/auth route, including session reads. The login page does not run this guard and keeps rendering a Sign In button that posts to the crashed route. (code-review)
  • #3 · 4/10 · pages/api/auth/[...nextauth].page.ts:64 · After the new OKTA-only guard, the AUTH_PROVIDER === 'OKTA' checks at lines 64, 74 and 200 are always true, and login.page.tsx still derives signInAuthProviderId and isOkta from the env var. The leftover branching suggests other providers still exist. · ✅ fixed in f850905
  • #4 · 3/10 · pages/login.page.tsx:81 · The login page still renders English-only strings ('Find help', the Okta sign-up hint, the subtitle) next to the now-translated Sign In button. These lines are unchanged by this PR. (code-review)
  • #7 · 3/10 · pages/api/auth/[...nextauth].page.test.ts:66 · The new 'configures only the Okta provider' test only checks the mock's own return value, so it never verifies the clientId, issuer, or scope passed to OktaProvider. (code-review)
  • #8 · 3/10 · pages/login.page.test.tsx:39 · The login tests share one context object whose cookie earlier tests overwrite, so 'should pass down props and render login' runs with the leftover impersonate cookie instead of an empty one. (code-review)
  • #9 · 3/10 · pages/login.page.tsx:24 · The Okta provider id is now a local literal in login.page.tsx, a separate literal in RouterGuard.tsx, and an implicit default in OktaProvider, with nothing keeping them in sync. (code-review)
  • #10 · 3/10 · pages/login.page.tsx:108 · With no session and no impersonate cookie, the handoff redirect-url cookie is cleared before signIn runs, so after Okta returns to /login the user lands on /accountLists instead of the handoff target. (code-review)
  • #11 · 3/10 · src/lib/extractCookie.ts:5 · extractCookie splits the whole header on name=, so a cookie whose name ends with the requested name (for example foo-mpdx-handoff.impersonate) is returned as a match. (code-review)
  • #5 · 2/10 · pages/login.page.tsx:34 · The removed t('Sign In with {{authProviderName}}') call leaves a dead key in the extracted locale files and a stale entry for the deleted login-apioauth test in the jest shard timings. (testing)
  • #12 · 2/10 · pages/api/auth/[...nextauth].page.test.ts:1 · The header comment explains the mocks by saying the guards run before either export is used, which no longer tells the whole story now that the options tests assert on the mocked NextAuth and OktaProvider. (code-review)
  • #13 · 2/10 · pages/api/auth/[...nextauth].page.ts:71 · The ?? "" fallbacks on OKTA_CLIENT_ID, OKTA_CLIENT_SECRET and OKTA_ISSUER can never apply after the unconditional guard on line 63, which also narrows them to string. (code-review)
  • #14 · 2/10 · pages/api/auth/[...nextauth].page.ts:212 · When Rollbar is off, spreading an Error into customData drops its message and stack, so console.error prints only the code. (code-review)
🔧 Fix suggestions (0)

No automated fixes for this review.

📦 Dependency impact

Blast radius: 0 files. None of the changed files has an importer in the index (the sign-in route and the login page are Next.js entry points).

📊 Review detail & stats

Generated: 2026-12-01T17:40:42Z · Day: Tuesday · Files changed: 9 (+117 -415 lines) in the whole PR; this pass 4 (+53 -52)
Risk score: 22 · CRITICAL · Required reviewer: senior maintainer

Risk factors detected: config_security_change (next.config.ts, whole PR); sign-in code under pages/api/auth/ and pages/login.page.tsx; scope single_feature for this pass; paths not in the risk map: CLAUDE.md, README.md

Deterministic evidence:

  • AST/static rules: none
  • CI snapshot: unavailable (local review)
  • Cross-repo context: none

Agent summary for this pass (bands: Critical 9-10 · High 7-8 · Important 5-6 · Suggestions 3-4):

Agent Critical High Important Suggestions Confidence
Code Review (/code-review xhigh) 0 0 2 6 H
Security Review Agent 0 0 0 0 H
Testing & Quality Review Agent 0 0 0 0 H
Standards Compliance Review Agent 0 0 0 0 M
UX & Accessibility Review Agent 0 0 0 0 H
Total 0 0 2 6 -

Three of this pass's findings (#12, #13, #14, 2/10) sit below the Suggestions band. Two findings from this pass matched earlier entries and kept their numbers (#1, #4); #6 to #14 are new.

Per-agent perspectives on blockers: none (no blockers).

Engine: code-review (from config) · effort xhigh (from config) · model opus (from config)
/code-review findings: found 12 · scored 11 · dropped 1 (scored findings under the
profile's cutoff may not appear in the lists above)

  • .claude/review/rules/security.md:81 security rules still describe the removed API_OAUTH provider and AUTH_PROVIDER gate: excluded path: .claude/review/rules/**

Review quality:

  • Average agent confidence: High · Consensus rate: 0% (no finding raised by two lanes) · Review time: 10 minutes
  • Findings suppressed by approved learnings: 0
💬 How to act on this review

Every finding above is numbered. Severity ≥ 7 findings carry a checkbox and must each be fixed or
dismissed
before this review counts as passed; lower severities are advisory. This repo runs
reviews locally only, so work this ledger with /agent-review:address in a Claude Code session.
It fixes or dismisses findings (a reason code and explanation are required for a dismissal) and
keeps this comment in sync. Valid codes: false-positive, intentional, pre-existing,
deferred, duplicate, insufficient-evidence, other.

@github-actions github-actions Bot added the needs-human-approval agent-review: a person must approve this PR label Nov 30, 2026
@jbirdjavi
jbirdjavi marked this pull request as ready for review December 1, 2026 00:32
@jbirdjavi

Copy link
Copy Markdown
Contributor Author

@jeff-clay could you review and approve this PR? Here's what it does and why it needs a person.

What it does: the MPDX web app had two ways to sign in: Okta, and an older option called API OAuth. Only Okta is turned on, on both mpdx.org and stage. This PR takes the old option out of the web app. The matching API change, CruGlobal/mpdx_api#3844, removes the API's half of it, plus an old SAML sign-in (an older single sign-on method) that only returns a server error today. Users won't see a difference: they keep signing in with Okta, and the button just says "Sign In". The help desk MCP sign-in isn't affected; on mpdx.org it already uses the Okta sign-in page.

Why: a sign-in path nobody uses is still a way in, and it's code someone has to keep safe. Removing it leaves one path to protect. If a server were ever set up with the old option, sign-in now stops with a clear error in the server logs instead of using it.

Why it needs a person: this repo treats sign-in code as a "one-way door." A mistake there could show one person's data to someone else or leak a secret, and that can't be taken back. That's why the review bot marks this PR as critical risk and won't approve it on its own: a code owner has to. I opened the PR, so I can't approve it myself.

Already checked: CI is green, and the automated review found no blockers. This PR and #3844 can merge in either order.

@jeff-clay

Copy link
Copy Markdown
Contributor

The code looks good to me. Two things before I approve:

  1. The preview never came up. https://MPDX-10415.d3dytjb8adxkk5.amplifyapp.com shows the Amplify "Welcome" page and /login is a 404, while the other open previews load. Can you check the Amplify build for this branch?
  2. Since [...nextauth].page.ts now throws unless AUTH_PROVIDER is OKTA, can you confirm in the Amplify console that it's OKTA or unset for the app, main, and staging? I don't have access to that account.

Small things, none blocking:

  • [...nextauth].page.ts and login.page.tsx still check AUTH_PROVIDER === 'OKTA' (isOkta, the provider ID). Those are always true now, so they could go.
  • "Sign In with {{authProviderName}}" is still in public/locales/en/translation.json and en-US. The next yarn extract will drop it.
  • .claude/review/rules/security.md still says to keep a guard that allows OKTA or API_OAUTH, so a later review may flag the new guard. Fine as its own PR, just sooner rather than later.

Once the preview loads I'll do the Okta sign-in check and approve.

@jbirdjavi jbirdjavi added Preview Environment Add this label to create an Amplify Preview and removed Preview Environment Add this label to create an Amplify Preview labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Preview branch generated at https://MPDX-10415.d3dytjb8adxkk5.amplifyapp.com

The startup guard already stops the server unless AUTH_PROVIDER is
OKTA, so the later AUTH_PROVIDER === 'OKTA' checks were always true.
The Okta provider is now always configured, sign out always goes to
the Okta sign-out URL, and the login page signs in with the 'okta'
provider id directly instead of deriving it from AUTH_PROVIDER. The
isOkta and signInAuthProviderId props are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

needs-human-approval agent-review: a person must approve this PR one-way-door Preview Environment Add this label to create an Amplify Preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants