Repository navigation
Fixes 28668: Keep SSO users signed in while their IdP session is alive - #34072
Conversation
The shipped OIDC defaults sent prompt=consent&max_age=0 on every authorize request. max_age=0 obliges the identity provider to demand credentials, so signing in again after an expired OpenMetadata session asked for a password even while the IdP session was alive. - Treat maxAge "0" or blank, and a blank prompt, as unset (one WARN for maxAge=0). OIDC_MAX_AGE and OIDC_PROMPT_TYPE now default to empty in openmetadata.yaml, the test and distributed configs and every compose file, and the SSO form no longer seeds maxAge 0. Admins who relied on max_age=0 to force a fresh login should set OIDC_PROMPT_TYPE=login. - Let /api/v1/auth/login request prompt=none per call (allow-listed, web flow only; MCP keeps its rule) so the browser can re-authenticate silently. - Make /api/v1/auth/refresh answer 401 and revoke the session when the OpenMetadata refresh token is expired, unknown or missing, instead of a 500. Unexpected failures release the lease and return a generic 500. - Correct the maxAge and prompt schema descriptions and SSO help docs.
…sers out When a token renewal needed user interaction, MSAL and public OIDC fell back to a popup, and every other failed refresh signed the user out, even while the identity provider session was still alive. - Renewers throw ReauthRequiredError instead of opening popups, and each SSO authenticator gains invokeSilentReauth, a top-level prompt=none redirect (MSAL acquireTokenRedirect, oidc-client signinRedirect, Auth0 loginWithRedirect, Okta signInWithRedirect, and /api/v1/auth/login?prompt=none for confidential clients). - AuthProvider tries one silent re-auth before signing out. ReauthGuard allows one redirect per tab every 3 minutes and one tab at a time; sibling tabs wait for the new token instead of redirecting as well. - A refresh failure carries the token it was meant to replace, and a waiting tab compares storage against that token. A throttled tab that handles its failure after a sibling recovered adopts the fresh token instead of waiting for a newer one and signing every tab out. - Breaker trips, network errors and Basic/LDAP keep the old sign-out, and a logout in progress never re-authenticates. - The loader stays up during the redirect, and the stored redirect path keeps its query string so the user lands back on the deep link. On /callback and /auth/callback the app never signs in on, or refreshes, the token left from before the redirect, expired or not, so the Okta, Auth0 and confidential callbacks mount and store the fresh one. - Start the proactive refresh timer after login and on cold load; MSAL schedules it from the ID token's exp. - Treat 'Invalid session.' as refreshable, and send the Okta and Auth0 callbacks' login_required to /signin instead of a raw error page. - Jest coverage for the new paths, and Playwright SSO scenarios 11 (deep link restored without /signin) and 12 (a dead IdP session signs out after one attempt, no loop).
… schedule A confidential OIDC session kept the provider refresh token from login but never used it, so OpenMetadata neither kept the provider session alive while the user was active nor noticed when the provider ended it. - Record on the session when the provider's tokens need renewing (their expires_in, at login and at every renewal). A refresh renews them with a refresh_token grant whenever they would lapse before the OpenMetadata token it issues, before rotating the OpenMetadata refresh token. - Cut the issued OpenMetadata token short to that schedule (120s floor) so an open browser always refreshes in time. Providers whose idle timeout counts refresh-token use, like Keycloak (5-minute tokens, 30-minute SSO idle), keep the user signed in while they are active. - Rejected grant (invalid_grant, invalid_token): revoke the session and answer 401; the browser re-authenticates silently. - No verdict (outage, unparseable response, invalid_client, unauthorized_client): keep the session and ask again in 5 minutes. - A successful grant never extends the session. Refresh tokens can outlive the provider's browser session (Entra ID's survive single sign-out), so only a new sign-in starts a new session lifetime. - Unit tests for the schedule, the refresher, the handler paths and the session store round trip; design doc and SSO token-validity help updated.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
|
✅ SSO Login Nightly — PASSED View workflow run · Commit
Totals: 103 passed · 0 failed · 0 flaky · 0 skipped · duration 26m 17s |
endKeycloakSession cleared each Keycloak cookie with its own concurrent
clearCookies({ name }) call. Playwright implements a filtered clear by
reading every cookie, clearing them all and adding back the ones that do
not match, so the calls added back each other's cookies and the IdP
session survived. Scenario 12 then got a code back from the prompt=none
redirect instead of login_required, on either Keycloak leg depending on
timing. One call with a name pattern clears them all.
| SessionService.ProviderTokens providerTokensAtLogin(OidcCredentials credentials, long now) { | ||
| // pac4j 6 re-parses the stored tokens on every to*Token() call; parse each once. | ||
| var providerRefreshToken = credentials.toRefreshToken(); | ||
| if (providerRefreshToken == null) { |
There was a problem hiding this comment.
how are we handling null values at the receiver side
…letion linear - A sign-in or refresh now hands SessionService an explicit ProviderTokenUpdate: NONE, Rescheduled or Replaced. No caller passes null any more to mean "leave the stored provider state alone", and the session builder applies the update with a single switch. A provider that renews without rotating its refresh token is a Rescheduled. - The OIDC completeRefresh returns the refreshed session, or throws AuthenticationException when the session ended while the refresh held its lease. handleRefresh already revokes the session and answers 401 for that exception. So refreshLeasedSession no longer depends on a helper that sometimes wrote the response itself. The 401 body is unchanged. - OidcProviderTokenRefresher maps a token response to one of two named outcomes, not an early return followed by the error path.
| if (!nullOrEmpty(requestedPrompt) && !isRequestable) { | ||
| LOG.debug("Ignoring unsupported prompt request parameter '{}'", requestedPrompt); | ||
| } | ||
| return isRequestable ? requestedPrompt : promptType; |
There was a problem hiding this comment.
When the browser sends prompt=none, it replaces the prompt the admin configured, including login. So prompt=login stops applying at the moment the OpenMetadata session ends.
Background: prompt=login tells the identity provider (IdP) to always ask for credentials. prompt=none tells it never to show a screen: it signs the user in silently or fails.
What happens with a confidential OIDC client and prompt=login configured:
- The user's OpenMetadata session expires while their IdP session is still alive.
/auth/refreshanswers 401, and the UI redirects to/api/v1/auth/login?prompt=none(the redirect scenario 11 checks).requestedPromptOrConfiguredreturnsnone, so the IdP signs the user back in without asking for a password.
A manual sign-in from /signin still sends prompt=login, so only the automatic re-login is affected. Two reasons it seems worth changing:
- Before this PR, a deployment with
prompt=logingot a password prompt when the session ended: the UI signed out, and the next sign-in sentlogin. That now changes without anyone touching the setting. - The rollout notes and the SSO help pages suggest
prompt=login"to force a fresh login every time" in place ofmax_age=0, but it no longer covers the session-end case.
A possible fix: let a requested none replace any configured prompt except login. The redirect is a full page, so the IdP can show its login page and the user still lands back on the page they were on. Replacing consent can stay, since deployments first started with the old defaults still have consent stored in the database.
private static final String FORCED_LOGIN_PROMPT = "login";
private String requestedPromptOrConfigured(String requestedPrompt) {
boolean isRequestable =
requestedPrompt != null && REQUESTABLE_PROMPTS.contains(requestedPrompt);
if (!nullOrEmpty(requestedPrompt) && !isRequestable) {
LOG.debug("Ignoring unsupported prompt request parameter '{}'", requestedPrompt);
}
// prompt=login is admin policy: a silent request must not bypass it.
boolean forcesLogin = FORCED_LOGIN_PROMPT.equalsIgnoreCase(promptType);
return isRequestable && !forcesLogin ? requestedPrompt : promptType;
}A test next to handleLogin_promptNoneRequest_overridesTheConfiguredPromptForWebLogin could configure login, request none, and check that the redirect still sends prompt=login (today it sends prompt=none). What do you think?
| if (outcome.isRejected()) { | ||
| deleteRefreshTokenIfPresent(omRefreshToken); | ||
| throw new AuthenticationException("Identity provider session ended"); | ||
| } |
There was a problem hiding this comment.
This is the branch where commit 3 (feat(auth): renew provider tokens on the provider's schedule) can end a confidential OIDC session early: when the IdP rejects the refresh-token grant, the OpenMetadata session is revoked. On main, OpenMetadata never contacts the IdP after login, so the session lasts sessionExpiry (7 days by default).
How much earlier it ends depends on the IdP:
- Keycloak ties regular (non-offline) refresh tokens, which the default
openid email profilescopes get, to its SSO session. With Keycloak's default 30-minute idle and 10-hour maximum, a user whose Keycloak session sees no activity for 30 minutes (laptop closed over lunch or overnight) has to sign in again, and no session outlives the 10-hour maximum. On main, they stay signed in for up to 7 days. - Entra ID, the IdP in OIDC SSO prompts to enter Azure password #28668, keeps refresh tokens valid after the user signs out (as the PR notes), so this branch wouldn't catch that sign-out.
The password prompts reported in #28668 come from the forced max_age=0 default and from users being signed out when renewal fails, which the other commits address. Commit 3 addresses the last root cause listed in the issue (the IdP's session lifetime not governing OpenMetadata's), which is a policy change rather than a fix for those prompts. It might be worth moving it to its own PR, so the policy (should the OpenMetadata session end with the IdP's, and for which IdPs?) and the mechanism can be decided on their own.
On the mechanism, OIDC Back-Channel Logout could be worth comparing: the IdP notifies OpenMetadata when the user logs out or an admin ends the session, instead of OpenMetadata inferring it from refresh-token failures. It is sent on logout rather than when an IdP session simply expires, and IdP support varies, so it may complement the refresh-token check rather than replace it. What do you think?
A browser-requested prompt=none replaced every configured prompt, including login. So once an OpenMetadata session ended, a deployment set to always ask for credentials signed the user back in silently at the identity provider. A requested none now yields to a configured prompt that includes login; the re-login is a full-page redirect, so the provider can show its form. It still replaces other prompts such as consent, which installs from the old defaults still have stored.
8dcc255 signs a confidential OIDC user out as soon as the identity provider rejects its refresh token. On Keycloak, whose refresh tokens die with its SSO session (30-minute idle and 10-hour maximum by default), a user back from a closed laptop then gets a password prompt where the sessionExpiry-long session used to carry on. That policy change goes beyond what #28668 needs, and on Entra ID it cannot see a sign-out, since Entra refresh tokens survive it. Put it behind oidcConfiguration.endSessionWithProvider (OIDC_END_SESSION_WITH_PROVIDER), off by default. Off, a login keeps nothing from the provider, a refresh never contacts it, and every JWT gets the full tokenValidity, including for sessions that still carry a renewal time from while it was on. On, the provider renewal works as before. The setting is in the SSO form for every OIDC provider, with help text, and in openmetadata.yaml, the test and distributed configs and the compose files.
Conflicts in AuthProvider.tsx and its test, against #34189's re-login landing fix: handledVerifiedUser now reads this branch's locationRef (pathname and search, so a stored redirect keeps its query string) in place of main's pathnameRef. Main's sign-in routing test mocks the location with a search string too.
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
Code Review ✅ Approved🔴 High risk · Authentication changes alter SSO reauthentication, session revocation, and provider-token renewal Comprehensive SSO session management overhaul that eliminates forced re-authentication when IdP sessions are alive. Implements silent re-authentication with OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
| Count | Rule |
|---|---|
| 11 | react-hooks/exhaustive-deps |
| 4 | no-restricted-imports |
| 1 | openmetadata-imports/no-circular-imports |
| 1 | openmetadata-imports/no-lower-layer-page-imports |
All findings
| Location | Rule | Message | |
|---|---|---|---|
| 🟡 | src/components/AppRouter/UnAuthenticatedAppRouter.tsx:21:1 |
openmetadata-imports/no-circular-imports |
This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency. |
| 🟡 | src/components/Auth/AppAuthenticators/MsalAuthenticator.tsx:306:8 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'handleRedirect'. Either include it or remove the dependency array. |
| 🟡 | src/components/Auth/AppAuthenticators/OidcAuthenticator.tsx:30:1 |
openmetadata-imports/no-lower-layer-page-imports |
Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here. |
| 🟡 | src/components/Auth/AppCallbacks/Auth0Callback/Auth0Callback.tsx:37:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'handleFailedLogin'. Either include it or remove the dependency array. |
| 🟡 | src/components/Auth/AppCallbacks/OktaCallback/OktaCallback.tsx:33:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'handleFailedLogin'. Either include it or remove the dependency array. |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:316:9 |
react-hooks/exhaustive-deps |
The 'onLoginHandler' function makes the dependencies of useMemo Hook (at line 1097) change on every render. Move it inside the useMemo callback. Alternatively, |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:408:6 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'navigate', 'setApplicationLoading', 'setCurrentUser', and 'setIsAuthenticated'. Either include them or remove |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:473:9 |
react-hooks/exhaustive-deps |
The 'resetUserDetails' function makes the dependencies of useMemo Hook (at line 1097) change on every render. To fix this, wrap the definition of 'resetUserDeta |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:685:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'handleRefreshFailed', 'handleStoreProtectedRedirectPath', 'setIsAuthenticated', and 'signOutAfterRefreshFailure' |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:687:9 |
react-hooks/exhaustive-deps |
The 'handleFailedLogin' function makes the dependencies of useMemo Hook (at line 1097) change on every render. Move it inside the useMemo callback. Alternativel |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:750:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has missing dependencies: 'authConfig?.provider', 'handledVerifiedUser', 'navigate', and 'resetUserDetails'. Either include them or remov |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:800:9 |
react-hooks/exhaustive-deps |
The 'initializeAxiosInterceptors' function makes the dependencies of useMemo Hook (at line 1097) change on every render. To fix this, wrap the definition of 'in |
| 🟡 | src/components/Auth/AuthProviders/AuthProvider.tsx:1086:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchAuthConfig'. Either include it or remove the dependency array. |
| 🟡 | src/utils/SSOUtils.ts:14:1 |
no-restricted-imports |
'../assets/img/icon-auth0.svg' import is restricted from being used by a pattern. Do not import SVG icons directly from assets/ paths; use the designated abstra |
| 🟡 | src/utils/SSOUtils.ts:19:1 |
no-restricted-imports |
'../assets/svg/ic-custom-oidc.svg' import is restricted from being used by a pattern. Do not import SVG icons directly from assets/ paths; use the designated ab |
| 🟡 | src/utils/SSOUtils.ts:20:1 |
no-restricted-imports |
'../assets/svg/ic-ldap.svg' import is restricted from being used by a pattern. Do not import SVG icons directly from assets/ paths; use the designated abstracti |
| 🟡 | src/utils/SSOUtils.ts:21:1 |
no-restricted-imports |
'../assets/svg/ic-saml.svg' import is restricted from being used by a pattern. Do not import SVG icons directly from assets/ paths; use the designated abstracti |
Fix locally (fast - only checks files changed in this branch):
make ui-checkstyle-changed
|
|



Describe your changes:
Fixes #28668
Related: #31346 (confidential OIDC path only; Basic and LDAP still answer 500), #33553 (the OpenMetadata token now ends before the IdP's tokens need renewing when a provider refresh token exists)
SSO users were sent back to the identity provider, often to a password or consent prompt, although their IdP session was still alive: the shipped OIDC defaults sent
prompt=consent&max_age=0, a failed silent renewal signed the user out (or opened a popup the browser blocked), and confidential OIDC sessions never consulted the provider. This PR stops forcing re-authentication, re-authenticates silently at the IdP (prompt=none) before ever signing a user out, and renews provider tokens on the provider's own schedule.Type of change:
High-level design:
Six commits: the change in three, reviewable separately, and three follow-ups from CI.
1.
fix(auth): stop forcing SSO re-login; 401 for dead refreshes (backend, config)maxAge"0"or blank and a blankpromptare treated as unset (one WARN for0).OIDC_MAX_AGE/OIDC_PROMPT_TYPEdefault to empty inopenmetadata.yaml, the test and distributed configs and every compose file; the SSO form no longer seedsmaxAge: 0./api/v1/auth/loginaccepts a request-scoped, allow-listedprompt=none(web flow only; MCP keeps its rule), so the browser can re-authenticate silently./api/v1/auth/refreshanswers 401 and revokes the session when the OpenMetadata refresh token is expired, unknown or missing (was a 500 echoing the token). Unexpected failures release the lease and return a generic 500.2.
fix(ui): re-authenticate silently instead of signing out (browser)ReauthRequiredErrorinstead of opening popups. Each authenticator gainsinvokeSilentReauth, a top-levelprompt=noneredirect: MSALacquireTokenRedirect, oidc-clientsigninRedirect, Auth0loginWithRedirect, OktasignInWithRedirect,/api/v1/auth/login?prompt=nonefor confidential clients.AuthProvidertries one silent re-auth before signing out.ReauthGuard(a localStorage record plus a per-tab id in sessionStorage) allows one redirect per tab per 3 minutes and one tab at a time. Sibling tabs wait for a replacement of the token their own refresh failed on (staleToken), so a throttled tab adopts a sibling's fresh token instead of signing every tab out. Breaker trips, network errors and Basic/LDAP keep the old sign-out; a logout in progress never re-authenticates./callbackand/auth/callbacknever sign in on, or refresh, the token left from before the redirect (the Okta, Auth0 and/auth/callbackhandlers exist only in the signed-out routes). The stored redirect keeps its query string, and the proactive timer is armed after login and on cold load.openmetadata-ui/src/main/resources/ui/docs/auth-coordinator-flows.md.3.
feat(auth): renew provider tokens on the provider's schedule (confidential OIDC)providerRenewalDueAtfrom the provider'sexpires_in. A refresh renews the provider tokens (refresh_token grant,OidcProviderTokenRefresher) whenever they would lapse before the OpenMetadata token it issues, and that token is cut short to the schedule (120 s floor), so an open browser always comes back in time. IdP sessions with an idle timeout (Keycloak: 5-minute tokens, 30-minute SSO idle) stay alive while the user is active.invalid_grant/invalid_tokenrevoke the session (401, then the browser's silent re-auth). Outages and client-configuration errors (invalid_client,unauthorized_client) are no verdict: the session keeps going and the provider is asked again in 5 minutes.docs/session-management-multi-node-design.md§6.7.4.
fix(auth): sign out a session OpenMetadata revoked (follow-up)/auth/refresh(confidential OIDC, SAML) answers401 Session revokedfor a session OpenMetadata revoked on purpose (the per-user session cap, an administrator), and the browser signs out instead of re-authenticating: undermaxActiveSessionsPerUsera re-established session would evict another of the user's sessions.5.
fix(ui): silent re-auth gaps the SSO scenarios found (follow-up)RefreshFailedError, sogetLoggedInUserDetailsno longer clears the token and flashes/signinunder the redirect the refresh-failed handler has started.invalid_grant) as a reason for oneprompt=noneattempt: oidc-client renews Keycloak public clients with the refresh token, not the iframe.6.
test(playwright): end the Keycloak session with a single cookie clear (follow-up)clearCookies({ name })by clearing every cookie and adding back the non-matching ones, so the helper's concurrent per-name calls added back each other's cookies and the "dead" IdP session survived scenario 12. One call with a name pattern fixes it.Alternatives rejected: sliding the OpenMetadata session on a successful refresh-token grant (not proof the IdP session is alive); popups for interaction-required errors (blocked without a user gesture); detecting a sibling's recovery by comparing token
exp(breaks once tokens are shortened to the IdP's lifetime).Compatibility and rollout:
max_age=0, including a stored"0", no longer forces a password prompt. Deployments that want that must setprompt=login(OIDC_PROMPT_TYPE=login).user_sessionstores sessions as JSON and the new field is optional; sessions created before the upgrade renew at their next refresh. The JSON Schema change is description-only.Tests:
Use cases covered
/auth/refreshanswers 401 (not 500) for an expired, unknown or missing refresh token and revokes the session.Unit tests
ProviderTokenScheduleTest(new),OidcProviderTokenRefresherTest(new),AuthenticationCodeFlowHandlerTest,SamlAuthServletHandlerTest,SessionServiceTest,SessionStoreContractTest. The 234 tests in the session and auth classes pass.ReauthGuard.test.ts(new),OktaCallback.test.tsx(new),AuthCoordinator.test.ts,AuthProvider.test.tsx,useApplicationStore.test.ts, the five*Authenticator.test.tsx,Auth0Callback.test.tsx,eventBus.test.ts,AuthProvider.util.test.ts.RefreshQueue.test.ts. The 766 tests in the auth suites pass, as does the full UI suite (1,619 suites; run in UTC, as CI does).ProviderTokenSchedule100%,OidcProviderTokenRefresher100%,SessionService80.0%,AuthenticationCodeFlowHandler43.3% (87.4% of its changed lines; the misses are constructor wiring, the callback's activation call and two refresh branches this PR only moved). UI whole-file 84.9% across the 16 changed source files.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
playwright/e2e/Auth/SsoScenarios.spec.ts: scenario 11 (silent re-auth restores the deep link without/signin) and scenario 12 (a dead IdP session signs out after one silent re-auth, no loop), with provider switches inplaywright/utils/sso-providers/(silent-reauth.ts, Keycloak and MSAL-mock). Not yet run: they need the local Keycloak SSO stack.Manual testing performed
Not yet exercised against a live identity provider; the unit and Jest runs above are the verification so far.
UI screen recording / screenshots:
Not attached yet. The visible change is small: when a session needs re-establishing, a brief loader replaces the
/signinpage and the user lands back on the same page.Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>My PR is linked to a GitHub issue via
Fixes #<issue-number>above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
For UI changes: I attached a screen recording and/or screenshots above.
I have added tests (unit / integration / Playwright as applicable) and listed them above.
I have added a test that covers the exact scenario we are fixing.
I have added the tag
Backward-Incompatible-Change:max_age=0no longer forces a password prompt (see Compatibility and rollout).