Repository navigation
Fixes #26311: Trust the SSO login landing page on the configured callback host - #33978
Conversation
…irect SSO login has been unusable since 2.0.0 on any deployment whose oidcConfiguration.serverUrl is not byte-identical to the browser's origin - the normal case behind an ingress, where serverUrl is often left at its http://localhost:8585 default. The frontend asks to land on <its own origin>/auth/callback, but the redirect allow-list added in 2.0.0 only ever derived its /auth/callback entry from serverUrl. Exact scheme+host+port+path matching then rejected the login with "Redirect URI must exactly match a trusted redirect URI" and a 400 that named no candidate. There was no config-only remedy: a root-relative redirect canonicalizes against the same stale config origin. Derive the origin the client actually reached the deployment on and trust it for OpenMetadata's own two fixed callback paths. X-Forwarded-Proto and X-Forwarded-Host are read first (Jetty's scheme/host only reflect the external hop when useForwardedHeaders is on, which is off by default and not surfaced by the shipped Docker or Helm configs), falling back to the connector's own view for a direct deployment. The derived origin is client-influenced, so it is only ever concatenated with /auth/callback and /mcp/callback, the scheme is restricted to http/https, and an origin carrying user-info, a path, a query or a fragment is discarded. A forged X-Forwarded-Host therefore buys nothing: the token rides the response back to whoever made the request, so the forger can only redirect themselves. Any other target still has to match a configured entry. An unparseable header is dropped rather than aborting validation of a legitimately configured candidate. Rejections now log the trusted candidate set at WARN, which the wire-facing 400 deliberately omits. Also corrects the callback documentation that sent reporters down the wrong path in the first place: the SSO settings placeholders advertised /auth/callback while the field's own default is /callback, and conf/openmetadata.yaml pointed at /api/v1/callback, which is not a route at all. The IdP redirect_uri is /callback (the server endpoint that performs the code exchange); /auth/callback is the UI route the server redirects to afterwards and must not be registered with the IdP. The two same-named responseType and callbackUrl fields are now documented as public-client vs confidential-client, including that GET /api/v1/system/config/auth reports the top-level one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Two defects in the origin lookup added by the previous commit, both found by asking whether X-Forwarded-Host can actually be relied on. It cannot: the repository ships no nginx config, Helm chart or ingress template, so the proxy layer is entirely the operator's choice. Read the closest hop, not the furthest. These headers are normally replaced rather than appended, but a proxy that appends leaves the caller's own value left-most - so reading from the left let a caller sending "X-Forwarded-Host: evil.example.com, om.example.org" choose the derived origin. Each further hop appends to the right, so the right-most value is the one written by the most trusted proxy. The previous comment justified the left-most read as "the original client hop", which is the correct rule for X-Forwarded-For and the opposite of what is wanted here. Resolve scheme and authority independently. AWS ALB sets X-Forwarded-Proto and X-Forwarded-Port but never X-Forwarded-Host, passing the client's Host through untouched; hand-rolled nginx behaves the same way, since X-Forwarded-Host there is opt-in. Reading the scheme only alongside a forwarded host resolved those deployments to the internal http hop and rejected their own login - the very bug this was meant to fix. Host is now also preferred over the connector's view, because getServerPort() reports the local listener when the header carries no explicit port and would otherwise graft :8585 onto a public origin. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…e SSO (#28870) A deployment reachable at more than one hostname (load balancer, DR site) needs the IdP-facing callback to follow the host the browser arrived on. Add the two config lists that carry the extra registered URLs: - authenticationConfiguration.additionalCallbackUrls: extra OIDC redirect_uri values. Top-level rather than inside oidcConfiguration because ConfigResource strips oidcConfiguration from the browser-facing auth config, and public clients build redirect_uri in the browser. - samlConfiguration.sp.additionalAcsUrls: extra Assertion Consumer Service URLs. sp.entityId stays single-valued. Both default to [], so single-hostname deployments are unaffected. Wire the env vars in conf/openmetadata.yaml and conf/openmetadata-h2-test.yaml (the latter also gains the missing additionalTrustedRedirectUris), and regenerate the TypeScript types and the dereferenced UI schema.
Add SecurityUtil.sameOriginCallbackUrl(requestOrigin, primary, additional): the configured additional callback URL on the origin the request arrived on, or null to keep the primary. An entry qualifies only when it shares the primary's path, so selection changes the host the identity provider returns to but never the endpoint, and it is returned exactly as configured because the token request must repeat redirect_uri byte for byte. The request origin is client-influenced, so a forged host can only pick a URL the operator already registered; a malformed entry is skipped rather than failing the login. Extract sameOrigin(URI, URI) out of sameRedirect so both comparisons share one scheme/host/port normalization.
The callback that completes a login arrives as a separate request, so the redirect_uri sent to the identity provider has to be remembered on the pending session for the token request to repeat it exactly. - UserSession gains idpRedirectUri. It is written only when set, and the class now ignores unknown properties: JsonUtils reads with a mapper that rejects them, so without both an older pod reading a newer pod's session mid rolling upgrade would fail. Sessions are a JSON blob in both stores, so no migration is needed. - SessionService.createPendingSession takes a PendingLoginState record instead of seven positional arguments. No behavior change yet: nothing sets idpRedirectUri until the OIDC handler starts selecting callback URLs.
A deployment answering on several hostnames sent every identity provider the single oidcConfiguration.callbackUrl, so logins from any other host failed at the IdP. - Web logins now send the additionalCallbackUrls entry registered for the host the request arrived on, falling back to the primary. The choice is recorded on the pending session and the token exchange reuses it, so the authorization and token requests carry the same redirect_uri even when the callback comes back through a different ingress. - MCP logins keep the primary: that flow is anchored to serverUrl end to end, so it is left exactly as it was. - The signin and logout redirects stay on the request host when it has a registered callback URL, instead of sending a secondary site's users to serverUrl. An unregistered or forged host still gets serverUrl. With no additional callback URLs configured, nothing reads the request's origin and every redirect is unchanged.
Public clients build the redirect_uri in the browser, so the server-side selection alone left them sending the primary callback URL from every host. - GET /api/v1/system/config/auth now returns additionalCallbackUrls. - getRedirectUri picks the additional callback URL registered for the host the page is served from, with the server's rules: same path as the primary, the primary wins on its own origin, and the configured string is returned untouched. Login, the auth config, and the SSO test-login popup all use it. - The SSO settings form gets an editable "Additional Callback URLs" list for OIDC providers; SAML and LDAP drop it with the other OIDC-only fields. The SAML additionalAcsUrls field stays hidden until the SAML side supports it. New strings are translated for every locale.
Login skips an additional callback URL that is malformed or points at a different endpoint, so a typo there only shows up as a login that quietly keeps the primary. Validate the list when the SSO configuration is saved: each entry must be an absolute http(s) URL, without user-info or a fragment, on the same path as the callback URL the identity provider is actually sent (the OIDC one for confidential clients, the top-level one for public clients). The rule lives in SecurityUtil.isAlternativeCallbackUrl, shared with the runtime selection, so the two cannot drift apart. The live identity provider probes still use only the primary: a disaster-recovery host is often unreachable from the primary site when the config is saved.
The SAML side had one static Saml2Settings, so every AuthnRequest carried the single sp.acs and logins from any other hostname failed at the IdP. - SamlSettingsHolder builds one Saml2Settings per configured ACS (sp.acs plus sp.additionalAcsUrls) and publishes them in a single snapshot, so a reload never mixes old and new entries. Entries are keyed by configured URL, never by request input. The entityId stays the same across all of them. - Login picks the additional ACS registered for the request host, using the same rule as OIDC, and records it on the pending session. The ACS callback validates against that recorded ACS instead of re-deriving it from headers. MCP logins keep the primary. - The ACS callback now checks Destination and Recipient against the ACS URL the login sent, via onelogin's SamlMessageFactory hook, rather than the URL the container saw. In strict mode behind a load balancer that URL is the internal hop, so the check failed even with a single ACS. That pre-existing bug is fixed here too. - The redirect allow-list trusts /auth/callback on the host of every configured ACS, and logs the trusted set when it rejects a redirect. Also removes the dead relayState field and setSaml2Settings.
The SP metadata advertised only sp.acs, so an identity provider that imports it would reject AuthnRequests from the other hostnames. It now lists each additional ACS as another AssertionConsumerService, all under the one entityID. Per-host metadata would be wrong here: IdPs key the SP on entityID, so two documents with the same entityID conflict. onelogin's template holds a single ACS and runs postProcessXml inside the Metadata constructors, before a subclass could hold the extra URLs. So the endpoints are added to the rendered document and the result is signed afterwards, which keeps them covered by the signature. With no additional ACS URLs the servlet serves exactly what getSPMetadata() returned before, so existing IdP registrations see no change.
- SamlValidator rejects an additional ACS URL that login could never select: it must be an absolute http(s) URL on the same path as sp.acs, the same rule the OIDC list is held to. At most 20 are accepted, since each one gets its own Saml2Settings. The error names the entry and is reported against sp.additionalAcsUrls. - The SSO settings form shows an editable "Additional ACS URLs" list in the Service Provider section. The primary ACS is still auto-filled from the admin's origin, so the help text explains these are for the other hostnames and must also be registered with the identity provider. New strings are translated for every locale.
Changed-line coverage was 83.9%; these tests bring it to 98.8%. - The SAML ACS callback validates with the ACS recorded at login and installs the destination-checking message factory. No unit test reached that part of handleCallback before. - SamlSettingsHolder: initialization from the live auth config, the uninitialized guard, and the SP-key, keystore and missing-key-material branches of the signing setup. - The SP metadata servlet over real HTTP: every ACS under one entityID. - Logout from a registered secondary host stays on that host. - The additional-URL checks run inside the SAML validator's entry point and the base authentication-field validation. - SecurityUtil: an unparseable primary, and a hostless trusted entry. The two token-exchange boundary tests now report the callback's status and body when they fail.
|
| Count | Rule |
|---|---|
| 3 | react-hooks/exhaustive-deps |
All findings
| Location | Rule | Message | |
|---|---|---|---|
| 🟡 | src/components/SettingsSso/SSOConfigurationForm/SSOConfigurationForm.tsx:334:30 |
react-hooks/exhaustive-deps |
React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead. |
| 🟡 | src/components/SettingsSso/SSOConfigurationForm/SSOConfigurationForm.tsx:435:5 |
react-hooks/exhaustive-deps |
React Hook useCallback has a missing dependency: 'scrollToFirstError'. Either include it or remove the dependency array. Outer scope values like 'parseValidatio |
| 🟡 | src/components/SettingsSso/SSOConfigurationForm/SSOConfigurationForm.tsx:694:6 |
react-hooks/exhaustive-deps |
React Hook useMemo has an unnecessary dependency: 'hideBorder'. Either exclude it or remove the dependency array. |
Fix locally (fast - only checks files changed in this branch):
make ui-checkstyle-changed|
✅ SSO Login Nightly — PASSED View workflow run · Commit
Totals: 94 passed · 0 failed · 0 flaky · 0 skipped · duration 19m 04s |
…28870) With #26311 and #28870 in one change, the OIDC and SAML redirect allow-lists no longer have a reason to follow different rules. The OIDC allow-list trusted /auth/callback on whatever origin the request claimed via X-Forwarded-Host or Host. A forged host could make a login land on itself: SsoRedirectBoundaryTest encoded exactly that ("a forged host can make the login land on itself"). It also left #26311 unfixed for any deployment whose request did not happen to name its public origin. The landing page is now trusted on the host of every configured OIDC callback URL: the primary oidcConfiguration.callbackUrl and each additionalCallbackUrls entry. Those have to be right for login to work at all, since the identity provider rejects any other redirect_uri, so they name the deployment's real hosts even when serverUrl is left at its localhost default. SAML already applied this rule to its configured ACS URLs; both now share SecurityUtil.originOf. Nothing on the redirect path reads the request any more, so the parameter #26311 threaded through requireRedirectUri and sendRedirectWithToken is gone again. ownUrl, used for the /signin and /logout redirects, now copies the origin from the configured callback URL that matched rather than from the headers that selected it. That resolves the three CodeQL java/unvalidated-url-redirection alerts on it. requestOrigin keeps its one legitimate job: choosing among URLs the operator registered with the identity provider, where a forged host can select nothing that was not already configured.
✅ Playwright Results — workflow succeededValidated commit ✅ 3408 passed · ❌ 0 failed · 🟡 5 flaky · ⏭️ 1 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) 49m 48s ⏱️ Max setup 4m 22s · max shard execution 19m 15s · max shard-job elapsed before upload 22m 34s · reporting 17s 🌐 212.06 requests/attempt · 2.02 app boots/UI scenario · 36.71% common-shard skew Optimization targets still in progress:
🟡 5 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 |
ownUrl kept the request's host only when an *additional* callback URL matched it, because sameOriginCallbackUrl returns null on the primary's own origin. A request on the primary callback host therefore always got serverUrl. In the #26311 setup this PR targets - serverUrl left at http://localhost:8585, oidcConfiguration.callbackUrl on the real host - login now worked, but logout and the missing-pending-session and silent-auth fallbacks still sent the browser to localhost:8585. SecurityUtil.registeredCallbackUrl now returns the configured callback URL on the request's host, primary or additional. ownUrl builds the redirect from that URL's base: the callback URL minus its trailing /callback. The suggested fix rebuilt it from the origin instead, but these redirects used serverUrl before, and serverUrl carries a base path that an origin would drop (https://host/openmetadata/callback must give https://host/openmetadata/logout). A callback URL that is not the /callback servlet's keeps serverUrl. The request origin still only selects among configured URLs, so an unregistered host keeps serverUrl. Reported by gitar-bot on #33978.
|
Review on #33978: multi-hostname/DR deployments are not a supported use case ("this is not a use-case. Lets not add edge-cases into the code"). This removes #28870's work entirely - the additionalCallbackUrls and sp.additionalAcsUrls settings, their generated types, form fields and translations, the per-ACS SAML settings and SP metadata, the recorded IdP redirect URI on the pending session, and the save-time validation - and leaves this PR as the #26311 fix only. Without additional hostnames nothing needs the request's host, so the #26311 fix no longer reads the request at all: - /auth/callback is also trusted on the host of the configured OIDC callback URL. That URL has to be right for login to work - the identity provider rejects any other redirect_uri - so it names the deployment's real host even when serverUrl is left at its localhost default. No forwarded or Host header can add a trusted target; requestOrigin and its X-Forwarded parsing are gone. - Logout and the two /signin fallbacks are built from the callback URL's base (the URL minus its trailing /callback), so they no longer bounce the user to a stale serverUrl. A base path survives; a callback URL that is not the /callback servlet's keeps serverUrl. - A rejected redirect logs the trusted targets at WARN. - The callback documentation fixes stay: the SSO form placeholders and conf/openmetadata.yaml now point at /callback, not /auth/callback or the non-existent /api/v1/callback.
Code Review ✅ Approved 1 closed / 1 findings🔴 High risk · Expands trusted OIDC landing redirects and changes authentication fallback destinations Fixes #26311 by trusting ✅ 1 closed✅ Edge Case: ownUrl ignores the primary callback host and falls back to stale serverUrl
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 |
|



Describe your changes:
Fixes #26311
The regression. Since 2.0.0, the login redirect allow-list trusted
/auth/callbackonly onoidcConfiguration.serverUrl. The frontend asks to land on<its own origin>/auth/callback, and matching is exact, so any deployment whoseserverUrlwas not byte-identical to the browser's origin was rejected withRedirect URI must exactly match a trusted redirect URI, with no config-only remedy. Behind an ingress,serverUrlis routinely left athttp://localhost:8585.The fix.
/auth/callbackis also trusted on the host of the configured OIDC callback URL (oidcConfiguration.callbackUrl). That URL has to be right for login to work at all, since the IdP rejects any otherredirect_uri, so it names the deployment's real host even whenserverUrlis stale./signinfallbacks (no pending session; silent-auth errors) are built from the callback URL's base (the URL minus its trailing/callback), so they no longer bounce the user to a staleserverUrl. A base path survives. A callback URL that is not the/callbackservlet's keepsserverUrl.X-Forwarded-*orHostheader can add a trusted target./mcp/callbackstays anchored onserverUrl./auth/callback, andconf/openmetadata.yamlpointed at a non-existent/api/v1/callback. Both now say/callback, and the YAML explains whichcallbackUrl/responseTypefields apply to public vs confidential clients./auth/callbackis the UI route the server redirects to after the code exchange and must not be registered with the IdP.Type of change:
High-level design:
N/A — small fix (8 files).
Tests:
Use cases covered
serverUrlleft athttp://localhost:8585and the callback URL on the real host — the login lands (real HTTP).serverUrlstale, the/signinfallback stays on the callback host (real HTTP).X-Forwarded-Hostcannot make a login land on itself: 400, and no session is persisted./mcp/callback, on the callback host stay rejected.Unit tests
AuthenticationCodeFlowHandlerTest(7 new),SecurityUtilTest(4 new,originOf),SsoRedirectBoundaryTest(3 new, over real HTTP through embedded Jetty and the production servlets).mvn package -pl :openmetadata-service -am -Dtest='org.openmetadata.service.security.**,ConfigResourceTest,SystemRepositoryTokenValidityTest,SystemRepositoryLdapConfigTest'→ 1,039 tests, 0 failures. UI: ESLint and Prettier clean on the two changed files.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
Not performed: reproducing needs an identity provider behind a proxy. The failure path is pinned by tests that fail without the fix.
UI screen recording / screenshots:
Not applicable — placeholder example text only (
.../auth/callback→.../callback).Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Bug fix:
SsoRedirectBoundaryTest.oidcLoginLandsOnTheCallbackHostWhenServerUrlIsStaleandAuthenticationCodeFlowHandlerTest.requireRedirectUri_trustsTheLandingOnTheCallbackHostWhenServerUrlIsStale, both referencing OIDC callback returns 404 after auth code exchange with Azure AD (confidential client) #26311.Note for maintainers:
Destinationis checked against the internal hop's URL. That is the single-domain setup this project supports, so it probably deserves its own issue.oidcClientConfig.jsondescribesresponseTypeas "Auth0 Client Secret Key." (a copy-paste). Fixing it regenerates about ten TS files, so it is better as its own PR.🤖 Generated with Claude Code