Skip to content

SSO e2e testing - #12739

Merged
SchrodingersGat merged 17 commits into
inventree:masterfrom
SchrodingersGat:sso-fix
Aug 30, 2026
Merged

SchrodingersGat merged 17 commits into
inventree:masterfrom
SchrodingersGat:sso-fix

Conversation

@SchrodingersGat

@SchrodingersGat SchrodingersGat commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

@SchrodingersGat SchrodingersGat added this to the 1.6.0 milestone Aug 29, 2026
@SchrodingersGat SchrodingersGat added bug Identifies a bug which needs to be addressed api Relates to the API security Relates to a security issue User Interface Related to the frontend / User Interface labels Aug 29, 2026
@netlify

netlify Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 1005a96
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a93660f6239ed0008507026
😎 Deploy Preview https://deploy-preview-12739--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 92 (🔴 down 6 from production)
Accessibility: 82 (🟢 up 1 from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@SchrodingersGat
SchrodingersGat requested review from matmair and a lite review from Copilot August 29, 2026 12:50

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.

Pull request overview

Adds end-to-end Playwright coverage for SSO using a mocked OIDC provider, and adjusts frontend/backend SSO flows to correctly surface and handle “pending provider signup” and SSO failure states (related to #10911).

Changes:

  • Add a mock OIDC server + Playwright tests that exercise real SSO redirects and the “provider signup” pending flow.
  • Add a new frontend /provider-signup page and routing to complete registration when allauth leaves the session in a pending flow.
  • Tighten SSO enablement handling (backend setting surfaced via server info; backend rejects social login when SSO is disabled).

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/frontend/yarn.lock Adds lock entries for the OIDC mock server dependency chain.
src/frontend/tests/pui_sso.spec.ts New Playwright e2e coverage for SSO login, registration completion, and disabled/closed registration paths.
src/frontend/tests/defaults.ts Adds mock OIDC server URL/port and mock SSO user identity used across config/tests.
src/frontend/src/states/UserState.tsx Captures auth context from failed session checks to support pending-flow routing.
src/frontend/src/states/states.tsx Extends server settings type to include sso_enabled.
src/frontend/src/states/ServerApiState.tsx Makes sso_enabled() respect the server-provided SSO enablement setting.
src/frontend/src/states/LocalState.tsx Improves host resolution to avoid incorrect origin fallback when frontend/backend differ.
src/frontend/src/router.tsx Adds lazy route for the new /provider-signup page.
src/frontend/src/pages/Auth/ProviderSignup.tsx New page to complete SSO registration for users without a local account.
src/frontend/src/pages/Auth/LoggedIn.tsx Surfaces allauth SSO callback errors via notification and redirects to login.
src/frontend/src/functions/auth.tsx Routes to /provider-signup when a pending provider-signup flow is detected; fixes SSO callback URL to use frontend origin + base.
src/frontend/src/components/buttons/SSOButton.tsx Adjusts SSO button behavior to rely on click handler (not anchor component).
src/frontend/playwright/mock-oidc-server.mjs Introduces minimal local OIDC provider for CI/local e2e.
src/frontend/playwright.config.ts Starts mock OIDC server and configures backend to use it for SSO during e2e runs.
src/frontend/package.json Adds oauth2-mock-server dev dependency.
src/frontend/lib/types/Auth.tsx Aligns auth context/flow typing with the flows used for pending provider signup.
src/frontend/lib/enums/ApiEndpoints.tsx Adds auth_provider_signup endpoint constant.
src/backend/InvenTree/InvenTree/sso.py Removes unused provider helper functions.
src/backend/InvenTree/InvenTree/auth_overrides.py Rejects SSO logins via adapter hook when SSO is globally disabled.
src/backend/InvenTree/InvenTree/api.py Exposes sso_enabled in server info settings payload.
Suppressed comments (1)

src/frontend/tests/pui_sso.spec.ts:109

  • This also assumes user/ returns an array. If the API starts returning a paginated envelope, the assertion will crash instead of correctly checking that no user was created. Parse both response shapes for robustness.
  const users = await api
    .get(`user/?search=${mockSsoUser.username}`)
    .then((response) => response.json());
  expect(
    users.find((user: any) => user.username === mockSsoUser.username)
  ).toBeUndefined();

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

Comment thread src/frontend/tests/pui_sso.spec.ts Resolved
@matmair

matmair commented Aug 29, 2026

Copy link
Copy Markdown
Member

Very intresting that this came up only now. On my deployments users are always pre-staged via an entra provisiong agent so that the fixed path never triggered but I imagine that is an industry specific solution.

@codecov

codecov Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.77%. Comparing base (69afe77) to head (1005a96).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12739      +/-   ##
==========================================
- Coverage   86.79%   86.77%   -0.02%     
==========================================
  Files        1461     1461              
  Lines       98012    98022      +10     
  Branches    11430    11356      -74     
==========================================
- Hits        85072    85063       -9     
- Misses      12874    12893      +19     
  Partials       66       66              
Flag Coverage Δ
backend 90.93% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 92.21% <ø> (ø)
Backend General 93.79% <ø> (ø)
Frontend 79.47% <ø> (-0.14%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Pull request overview

Copilot reviewed 22 out of 23 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/frontend/src/functions/auth.tsx:486

  • checkLoginState sets setLoginChecked(true) inside the !no_redirect branch and then calls setLoginChecked(true) again unconditionally at the end of the function. This double update is redundant and can make state changes harder to reason about.
  } else if (!no_redirect) {
    setLoginChecked(true);

    // A user authenticated via SSO, but with no matching local account, is

@SchrodingersGat
SchrodingersGat merged commit a205717 into inventree:master Aug 30, 2026
46 checks passed
@SchrodingersGat
SchrodingersGat deleted the sso-fix branch August 30, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API bug Identifies a bug which needs to be addressed security Relates to a security issue User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSO Authentication fails with 401

3 participants