Repository navigation
fix(e2e): restore SSO security config with an admin PAT, not a session token - #31578
Conversation
…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>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
✅ Playwright Results — workflow succeededValidated commit ✅ 549 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking 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:
🟡 1 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
|
Changes have been cherry-picked to the 2.0 branch. |
…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)
|
Failed to cherry-pick changes to the 1.13 branch. |
Code Review ✅ ApprovedSwaps 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. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
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
mainand2.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.updateSecurityConfigcallsauthorizer.authorizeAdmin, which readsisAdminoffthe User entity (
SubjectContext.isAdmin()). So the restorePUT403s on every provider leg.Adding the SSO user to
adminPrincipalswould not have helped either:reloadSecuritySystem→reinitializeAuthSystemre-registers the authenticator and authorizer but never re-bootstraps adminusers, so that flag only flips at boot.
The missed spec.
OktaSelfSignupClaims.spec.tsinlines its own swap/restore instead of goingthrough
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:
High-level design:
Use a credential that is neither session-bound nor provider-scoped. Three candidates, only one
clears both bars:
validateSessionProviderIsCurrentauthorizeAdminisAdmin=falsesessionIdclaimJwtFilter.validateSessionBoundTokenreturns early when the JWT carries nosessionIdclaim, so theSSO-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, andisInternallyIssuedTokenexempts OM-issued tokens from principal-domain enforcement. It also carriespreferred_username(JWTTokenGenerator), which is what lets it resolve under thejwtPrincipalClaimsMapping: ['username:preferred_username']scenario inOktaSelfSignupClaims— thesharpest risk in this approach, and the one the CI run below confirms.
swapSecurityConfigmints the PAT before applying the override, so a failure there aborts ratherthan 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-
afterAllblocks #31554 had to add — net−148/+86 lines.
OktaSelfSignupClaimsis converted onto the shared helper so it can't drift again.Known limitation, deliberately not addressed here: any
afterAllrestore failure still leaves theserver 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
original security configuration afterwards, on a server that has since rejected the pre-swap session.
jwtPrincipalClaimsMappingthat resolves username frompreferred_username.SSOSessionLimitno 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
Dispatched
SSO Login Nightlywithsso_provider=allagainst this branch:run 31875231829 — all three legs green.
okta405keycloak-azure-samlkeycloak-azure-saml-crosssite29/29 tests executed — no skips, no retries.
npx tsc --noEmit -p playwright/tsconfig.json— clean on all six changed files.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:
Fixes <issue-number>: <short explanation>— no issue exists; title follows thefix(e2e):convention used by fix(e2e): use SSO-provider token for security-config restore in afterAll #31554.Bug fix:
reproduce it directly; all three provider legs failed before and pass after.
🤖 Generated with Claude Code