Skip to content

fix(e2e): restore SSO security config with an admin PAT, not a session token - #31578

Merged
chirag-madlani merged 2 commits into
mainfrom
fix/sso-e2e-restore-with-admin-pat
Aug 15, 2026
Merged

chirag-madlani merged 2 commits into
mainfrom
fix/sso-e2e-restore-with-admin-pat

Conversation

@chirag-madlani

Copy link
Copy Markdown
Collaborator

Describe your changes:

No linked issue — this is a CI regression on main, follow-up to #31554 (which followed #31423).
Happy to open one and link it if maintainers prefer; flagging rather than inventing a number.

The SSO Login Nightly has been red on both main and 2.0
(main run,
2.0 run).
#31554 diagnosed the 401 correctly but its fix traded it for a 403, and it missed one spec
entirely. I fixed both.

The 403. #31554 replaced the pre-swap basic-auth token in the restore closure with a JWT from a
fresh SSO login. That authenticates — but the JWT belongs to the self-signed-up IdP user, and
SystemResource.updateSecurityConfig calls authorizer.authorizeAdmin, which reads isAdmin off
the User entity (SubjectContext.isAdmin()). So the restore PUT 403s on every provider leg.
Adding the SSO user to adminPrincipals would not have helped either: reloadSecuritySystem →
reinitializeAuthSystem re-registers the authenticator and authorizer but never re-bootstraps admin
users, so that flag only flips at boot.

The missed spec. OktaSelfSignupClaims.spec.ts inlines its own swap/restore instead of going
through swapSecurityConfig, so #31554 never touched it and it still reused the pre-swap admin token
→ 401. Because it sorts first in the Okta leg, its failed restore left the server in SSO mode and
every later spec died on POST /api/v1/auth/login → 405 HTTP method POST is not supported.

Type of change:

  • Bug fix

High-level design:

Use a credential that is neither session-bound nor provider-scoped. Three candidates, only one
clears both bars:

credential validateSessionProviderIsCurrent authorizeAdmin
pre-swap admin session token (pre-#31554) ✗ 401 — session minted under the decommissioned provider ✓
fresh SSO-login JWT (#31554) ✓ ✗ 403 — self-signed-up IdP user, isAdmin=false
admin personal access token (this PR) ✓ — no sessionId claim ✓ — belongs to the real admin

JwtFilter.validateSessionBoundToken returns early when the JWT carries no sessionId claim, so the
SSO-27 provider check added in #31423 never runs against a PAT. It stays verifiable after the swap
because every provider payload keeps OpenMetadata's own JWKS in publicKeyUrls, and
isInternallyIssuedToken exempts OM-issued tokens from principal-domain enforcement. It also carries
preferred_username (JWTTokenGenerator), which is what lets it resolve under the
jwtPrincipalClaimsMapping: ['username:preferred_username'] scenario in OktaSelfSignupClaims — the
sharpest risk in this approach, and the one the CI run below confirms.

swapSecurityConfig mints the PAT before applying the override, so a failure there aborts rather
than stranding the server in SSO mode. The returned restore function no longer takes an ssoToken,
which lets the four other specs drop the re-login-in-afterAll blocks #31554 had to add — net
−148/+86 lines. OktaSelfSignupClaims is converted onto the shared helper so it can't drift again.

Known limitation, deliberately not addressed here: any afterAll restore failure still leaves the
server in SSO mode with no recovery, which is why a single bad spec takes down a whole job. This PR
removes the known cause but not that fragility; a global teardown that force-restores from a PAT
would contain it. Worth a follow-up rather than widening this diff.

Tests:

Use cases covered

  • Admin swaps the server to Okta / Keycloak SAML / confidential OIDC for a suite and restores the
    original security configuration afterwards, on a server that has since rejected the pre-swap session.
  • Restore succeeds under a jwtPrincipalClaimsMapping that resolves username from preferred_username.
  • Restore succeeds without any live SSO session (SSOSessionLimit no longer needs a survivor token).

Unit tests

Not applicable — this PR changes Playwright test infrastructure; there is no product code to unit test.

Backend integration tests

Not applicable — no backend changes.

Ingestion integration tests

Not applicable — no ingestion changes.

Playwright (UI) tests

The changed specs are the tests. Files updated: playwright/utils/ssoAuth.ts,
playwright/e2e/Auth/{SSOLogin,SSORenewal,SSOSessionLimit,OktaSessionRenewalPublic,OktaSelfSignupClaims}.spec.ts.

Manual testing performed

  1. Dispatched SSO Login Nightly with sso_provider=all against this branch:
    run 31875231829 — all three legs green.

    Job Before (main) After
    okta 0 passed; first restore 401 → rest died on 405 10 passed (37.5s)
    keycloak-azure-saml 5 passed, then restore 403 → cascade 13 passed (3.7m)
    keycloak-azure-saml-crosssite 5 passed, then restore 403 → cascade 6 passed (9.4s)

    29/29 tests executed — no skips, no retries.

  2. npx tsc --noEmit -p playwright/tsconfig.json — clean on all six changed files.

  3. CI checkstyle sequence (organize-imports → eslint --fix → prettier) — produces no further diff.

UI screen recording / screenshots:

Not applicable — test-only change, no product UI is touched.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation> — no issue exists; title follows the
    fix(e2e): convention used by fix(e2e): use SSO-provider token for security-config restore in afterAll #31554.
  • My PR is linked to a GitHub issue — see note at the top.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: not applicable.
  • For UI changes: not applicable (test-only).
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Bug fix:

  • I have added a test that covers the exact scenario we are fixing — the five changed specs
    reproduce it directly; all three provider legs failed before and pass after.

🤖 Generated with Claude Code

…n token

#31554 traded a 401 for a 403. It replaced the pre-swap basic-auth token in
the restore closure with a JWT from a fresh SSO login, which authenticates —
but that JWT belongs to the self-signed-up IdP user, and
`SystemResource.updateSecurityConfig` calls `authorizer.authorizeAdmin`.
`SubjectContext.isAdmin()` reads `isAdmin` off the User entity, so the restore
PUT 403s on every provider leg. Adding the SSO user to `adminPrincipals` would
not have helped either: `reloadSecuritySystem` -> `reinitializeAuthSystem`
re-registers the authenticator and authorizer but never re-bootstraps admin
users, so the flag only flips at boot.

Mint a personal access token for the admin *before* the swap and restore with
that. `JwtFilter.validateSessionBoundToken` returns early when the JWT carries
no `sessionId` claim, so `validateSessionProviderIsCurrent` — the SSO-27 check
that started this — never runs against it, and the token belongs to the real
admin so `authorizeAdmin` passes. It stays verifiable after the swap because
every provider payload keeps OpenMetadata's own JWKS in `publicKeyUrls`, and
`isInternallyIssuedToken` exempts OM-issued tokens from principal-domain
enforcement. The PAT also carries `preferred_username`, so it resolves under
the `jwtPrincipalClaimsMapping` scenarios in OktaSelfSignupClaims.

`OktaSelfSignupClaims.spec.ts` was missed by #31554 entirely — it inlines its
own swap/restore rather than going through `swapSecurityConfig`, so it still
reused the pre-swap admin token and 401'd. Because it sorts first in the Okta
leg, its failed restore left the server in SSO mode and every later spec died
on `POST /api/v1/auth/login -> 405`. Converted it to `swapSecurityConfig`.

The restore function no longer takes an `ssoToken`, which drops the
re-login-in-afterAll blocks the four other specs had to carry.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 15, 2026 10:12

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Aug 15, 2026
@chirag-madlani chirag-madlani added the To release Will cherry-pick this PR into the release branch label Aug 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 1163eab06964d6543e1973ac4f840eb39afc5183 in Playwright run 31879112584, attempt 1.

✅ 549 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 27m 59s

⏱️ Max setup 3m 1s · max shard execution 18m 29s · max shard-job elapsed before upload 22m 11s · reporting 5s

🌐 214.50 requests/attempt · 2.83 app boots/UI scenario · 0.54% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 214.5 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.83 per UI scenario (1620 boots / 572 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 143 0 0 0 0 0
🟡 Shard chromium-02 131 0 1 0 0 0
✅ Shard chromium-03 124 0 0 0 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 14 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 10 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 1 flaky test(s) (passed on retry)
  • Pages/Entity.spec.ts › Tier Add, Update and Remove (shard chromium-02, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@chirag-madlani
chirag-madlani added this pull request to the merge queue Aug 15, 2026
Merged via the queue into main with commit d9cc62c Aug 15, 2026
84 of 85 checks passed
@chirag-madlani
chirag-madlani deleted the fix/sso-e2e-restore-with-admin-pat branch August 15, 2026 12:59
@github-actions

Copy link
Copy Markdown
Contributor

Changes have been cherry-picked to the 2.0 branch.

github-actions Bot pushed a commit that referenced this pull request Aug 15, 2026
…n token (#31578)

#31554 traded a 401 for a 403. It replaced the pre-swap basic-auth token in
the restore closure with a JWT from a fresh SSO login, which authenticates —
but that JWT belongs to the self-signed-up IdP user, and
`SystemResource.updateSecurityConfig` calls `authorizer.authorizeAdmin`.
`SubjectContext.isAdmin()` reads `isAdmin` off the User entity, so the restore
PUT 403s on every provider leg. Adding the SSO user to `adminPrincipals` would
not have helped either: `reloadSecuritySystem` -> `reinitializeAuthSystem`
re-registers the authenticator and authorizer but never re-bootstraps admin
users, so the flag only flips at boot.

Mint a personal access token for the admin *before* the swap and restore with
that. `JwtFilter.validateSessionBoundToken` returns early when the JWT carries
no `sessionId` claim, so `validateSessionProviderIsCurrent` — the SSO-27 check
that started this — never runs against it, and the token belongs to the real
admin so `authorizeAdmin` passes. It stays verifiable after the swap because
every provider payload keeps OpenMetadata's own JWKS in `publicKeyUrls`, and
`isInternallyIssuedToken` exempts OM-issued tokens from principal-domain
enforcement. The PAT also carries `preferred_username`, so it resolves under
the `jwtPrincipalClaimsMapping` scenarios in OktaSelfSignupClaims.

`OktaSelfSignupClaims.spec.ts` was missed by #31554 entirely — it inlines its
own swap/restore rather than going through `swapSecurityConfig`, so it still
reused the pre-swap admin token and 401'd. Because it sorts first in the Okta
leg, its failed restore left the server in SSO mode and every later spec died
on `POST /api/v1/auth/login -> 405`. Converted it to `swapSecurityConfig`.

The restore function no longer takes an `ssoToken`, which drops the
re-login-in-afterAll blocks the four other specs had to carry.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit d9cc62c)
@github-actions

Copy link
Copy Markdown
Contributor

Failed to cherry-pick changes to the 1.13 branch.
Please cherry-pick the changes manually.
You can find more details here.

@gitar-bot

gitar-bot Bot commented Aug 15, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Swaps the E2E security config restore mechanism to use an admin personal access token instead of a session token or fresh SSO login, fixing 401/403 authorization failures across all SSO test suites. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants