Repository navigation
fix(sso): return clear errors and keep login working on misconfiguration - #37741
Conversation
…eason The confidential OIDC callback answered a provider that refused the sign-in, a code exchange that failed or never answered (a wrong client secret among them) and a user the deployment may not provision with a raw 500 page. It now redirects to /signin?error=<code> with one of three fixed codes, and the reported detail stays in the server log. The sign-in page shows a translated message for the code and does not auto-redirect to the provider while it shows one. A sign-in started by an MCP client keeps the error status its callback reads. Release testing, SSO row: OC-07, OC-14, OC-17, ID-13. ADR:2026-11-12-a-failed-sso-sign-in-returns-to-the-sign-in-page
…thm changes tokenValidationAlgorithm names the identity provider's signing algorithm, but the server also signed and verified its own bot, personal access, session and MCP tokens with it, so changing it (to RS512, say) made all of them fail at once. The server now signs its own tokens with RS256 and verifies them with the RSA algorithm they name; the setting applies to the provider's tokens only. MCP discovery advertises RS256 for the tokens the server issues. Release testing, SSO row: OP-13. ADR:2026-11-12-openmetadata-signs-its-own-tokens-with-rs256
- A configuration the server cannot apply (a failing LDAP bind, a keystore it cannot read, LDAPS without a trust store) is put back to the previous one and refused with 400 and the reason, instead of staying stored behind a 500 or a 401. - A PUT also refuses, without contacting the provider, a client authentication method the server cannot perform, and SAML request or metadata signing without the SP certificate and key. Full validation also checks the method against the provider's discovery document. - LDAPS without a trust store type fails with a readable reason. - A PATCH is filtered by the provider it leaves in place, so it can switch provider, and a PATCH that only sets values the provider does not use is refused instead of answering 204. Release testing, SSO row: OC-15, SA-11, CF-02, CF-03, LD-12. ADR:2026-11-12-a-security-configuration-save-applies-in-full-or-is-refused
… SAML response Two first SAML sign-ins of one new user raced to create the account and the loser got a 500. It now signs in to the account the winner created, as the OIDC sign-in already does, through a helper both now share in UserUtil. A post to the assertion consumer service that is no SAML response is refused with 400 instead of a 500. Release testing, SSO row: the SAML first-login race and SA-17. Adds tests for SA-03, which #37436 already fixed.
❌ 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 |
| AuthProvider provider = authConfig == null ? null : authConfig.getProvider(); | ||
| FieldError error = null; | ||
| if (provider == AuthProvider.SAML && authConfig.getSamlConfiguration() != null) { | ||
| error = SamlValidator.validateSecurityConfiguration(authConfig.getSamlConfiguration()); |
There was a problem hiding this comment.
A PUT now refuses SAML request signing that uses a keystore. SamlValidator.validateSecurityConfiguration requires sp.spX509Certificate and sp.spPrivateKey whenever sendSignedAuthRequest or signSpMetadata is true. But the sign-in code, SamlSettingsHolder.putSpCredentials, accepts either those PEM values or keyStoreFilePath + keyStoreAlias + keyStorePassword, and conf/openmetadata.yaml documents that route through SAML_KEYSTORE_*.
To hit it: take a deployment that signs SAML requests with a JKS keystore and has no PEM values. Do a GET and then a PUT of /v1/system/security/config, even one that only changes adminPrincipals. It now answers 400 "SP X509 certificate is required when request signing is enabled", where before this PR it succeeded. Every PUT stays blocked until the deployment moves to PEM credentials.
PATCH already ran this validator before this PR, so the UI had the gap already. This change extends it to PUT, which was the only path still working for these deployments.
There was a problem hiding this comment.
Fixed in e63dbea. SamlValidator.validateSecurityConfiguration now asks SamlSettingsHolder.readsSpCredentialsFromKeyStore, the same check putSpCredentials uses to pick the keystore. Request signing with keystore path + alias + password and no PEM values now passes on PUT and PATCH. PEM values are still required where sign-in reads no keystore: an incomplete keystore, or metadata signing on its own.
Guard: SsoSamlLoginIT#requestSigningWithAKeyStoreIsSavedAndReadBack. It PUTs with a real JKS, GETs, PUTs again with an adminPrincipals change, then checks the sign-in request carries a Signature. It was RED on the previous head (400 "SP X509 certificate is required when request signing is enabled") and is GREEN now. Unit: SamlValidatorTest#validateSecurityConfigurationAcceptsSignedRequestsWithAKeyStore and #validateSecurityConfigurationNeedsPemCredentialsWhereSignInReadsNoKeyStore.
| void samlConfigurationThatCannotBeLoadedIsNotSaved() { | ||
| SecurityConfiguration broken = securityConfig.baselineCopy(); | ||
| broken | ||
| .getAuthenticationConfiguration() | ||
| .getSamlConfiguration() | ||
| .getSecurity() | ||
| .withSendSignedAuthRequest(true) | ||
| .withKeyStoreFilePath("/nonexistent/om-sso-it-keystore.jks") | ||
| .withKeyStoreAlias("sp") | ||
| .withKeyStorePassword("keystore-password"); | ||
|
|
||
| assertRefusedAndNothingSaved(broken); |
There was a problem hiding this comment.
This test does not reach the rollback it is named for. The baseline from SsoConfigs.saml(...) has no SP certificate or key. So turning on sendSignedAuthRequest with a keystore path gets refused by the new pre-write check (requireApplicable, see the comment on SystemRepository.java:1996) before anything is written. The 400 and "nothing saved" assertions pass, but the store, reload and restore path never runs.
The ADR lists this test as a guard for "a keystore it cannot read". As written, only the two LDAP cases (CF-03 bind failure and LD-12) cover the rollback.
There was a problem hiding this comment.
Rewritten in eb36e49. The case now points at a file that exists but is not a keystore. With e63dbea it passes the pre-write check, is stored, and fails when the reload loads the keystore.
It asserts that the 400 says the configuration could not be applied, so it got past requireApplicable, and that the stored, running and GET-read configurations are the previous ones. With the put-back call removed it fails on "the refused save was stored", together with both LDAP cases. With the put-back in place it passes.
| private void restoreSecurityConfiguration(SecurityConfiguration configuration) { | ||
| systemRepository.createOrUpdate( | ||
| new Settings() | ||
| .withConfigType(AUTHENTICATION_CONFIGURATION) | ||
| .withConfigValue(configuration.getAuthenticationConfiguration())); | ||
| systemRepository.createOrUpdate( | ||
| new Settings() | ||
| .withConfigType(AUTHORIZER_CONFIGURATION) | ||
| .withConfigValue(configuration.getAuthorizerConfiguration())); | ||
| SettingsCache.invalidateSettings(AUTHENTICATION_CONFIGURATION.toString()); | ||
| SettingsCache.invalidateSettings(AUTHORIZER_CONFIGURATION.toString()); |
There was a problem hiding this comment.
The restore does not check whether its writes worked. SystemRepository.createOrUpdate catches most write errors and returns a 500 Response rather than throwing, and both return values are ignored here.
If either restore write fails after the reload failed, the caller gets 400 "it was not saved", but the rejected configuration stays in the database. Other servers and the next restart then load it, which is the situation the new ADR is meant to rule out.
Separately, the restore writes the snapshot read at the start of the request without checking whether the rows changed since. The PATCH write is guarded by updateSecurityConfigurationIfCurrent, but the restore is not. A save made by another admin while this request waits on a slow LDAP bind is overwritten, even though that admin was told it succeeded.
There was a problem hiding this comment.
Fixed in 8a5d9a6.
- The put-back is now
updateSecurityConfigurationIfCurrent(previous, written), wherewrittenis the exact JSON this request stored (the write now returns it). So it only replaces this save. A save that landed meanwhile is kept, and the refused save is answered 412. - A put-back that throws is logged at ERROR and answered 500: "...putting the previous one back failed, so the refused configuration may still be stored...". It no longer reports 400 "not saved".
- PUT now writes with the same compare-and-set as PATCH, against the rows it read, so what it puts back is what it replaced. A PUT racing another save gets 412, like PATCH. Its writes throw instead of returning an ignored 500
Response. - After a 412 the server applies what is stored through
reloadIfStoredChanged. A failure there is logged, so the caller still gets the 412.
Guards:
SsoSecurityConfigApplyIT#aSaveMadeWhileARefusedOneWaitsOnTheDirectoryIsKeptholds the LDAP bind while another server's save lands. It was RED as 400 with that save undone, and is GREEN as 412 with the save kept.SystemResourceSecurityConfigApplyTestcovers a failed put-back write (500) and a save made meanwhile (412). Both were RED as 400 before.
| so tokens issued by earlier releases under another setting keep working. Any other algorithm on | ||
| a token carrying the server's key id is refused. | ||
| - `tokenValidationAlgorithm` applies only to the identity provider's tokens. | ||
| - The MCP OpenID discovery document advertises RS256 for the tokens the server issues. |
There was a problem hiding this comment.
This contradicts docs/decisions/2026-10-19-mcp-oauth-discovery-stays-inside-the-base-path.md, which is still Accepted and says at line 30 that id_token_signing_alg_values_supported is the configured tokenValidationAlgorithm. Neither record says it supersedes the other, so the tree now holds two Accepted decisions that disagree on the same discovery field.
There was a problem hiding this comment.
Checked the code. Discovery advertises JWTTokenGenerator.SIGNING_ALGORITHM (RS256), and every token the server issues is signed with it, MCP access tokens included; MCP issues no ID tokens. So the code matches the 2026-11-12 record, and only the older record was stale.
287d5eb adds a v2 amendment to the 2026-10-19 record (a Revisions entry and ## Amendment — 2026-11-16) that replaces that clause. The RS256 record now points at it.
Guard: OAuthHttpStatelessServerTransportProviderTest#openIdDiscoveryAdvertisesTheAlgorithmOfTheTokensTheServerIssues, with the provider on RS512. It is RED when discovery follows tokenValidationAlgorithm (RS512 advertised, RS256 tokens) and GREEN now. check_decision_records.py is clean.
A PUT, and a PATCH before it, refused SAML request signing whose SP key and certificate come from a keystore (keyStoreFilePath, keyStoreAlias and keyStorePassword, the SAML_KEYSTORE_* route in conf/openmetadata.yaml) with "SP X509 certificate is required when request signing is enabled", although sign-in signs with that keystore. A GET and then a PUT of such a deployment's configuration answered 400. The save check now asks SamlSettingsHolder.readsSpCredentialsFromKeyStore, which sign-in uses to choose its credentials, and needs the PEM values only where sign-in reads no keystore: an incomplete keystore, or metadata signing on its own.
The case set request signing with a keystore on a configuration without SP PEM values, so the check made before anything is written refused it and the store, apply and put-back path never ran. It now names a file that exists but is not a keystore. The save passes the check, is stored, and fails when the server loads the keystore. The case checks that the 400 says the configuration could not be applied, and that the stored, running and read configurations are the previous ones. With the put-back removed it fails on "the refused save was stored".
…rt a failed put-back When the server could not apply a saved security configuration, it wrote the previous one back with createOrUpdate, which answers a failed write with a 500 Response that was ignored, and it wrote it whatever the rows held by then. - Putting the previous configuration back is a compare-and-set against the JSON the refused save wrote, which the write now returns. A save made meanwhile, for example by another admin while this one waited on a slow LDAP bind, is kept and the refused save is answered 412. - A put-back that fails is logged and answered 500, saying the refused configuration may still be stored, instead of 400 "it was not saved". - PUT writes with the same compare-and-set as PATCH, over the rows it read, so what it puts back is what it replaced; a PUT racing another save is answered 412, as a PATCH is. Its writes throw instead of returning an ignored error response. - After a 412 the server applies what is stored with reloadIfStoredChanged; if that fails it is logged, so the caller still gets the 412.
…algorithm The 2026-10-19 MCP discovery record said id_token_signing_alg_values_supported is the configured tokenValidationAlgorithm, while the 2026-11-12 RS256 record says the server signs its own tokens with RS256 whatever that setting is, and discovery advertises RS256. The code already does the latter: discovery advertises JWTTokenGenerator.SIGNING_ALGORITHM, which every token the server issues, MCP access tokens included, is signed with. The older record gets a v2 amendment that replaces that clause, and the RS256 record points at it. A unit test checks that discovery advertises the algorithm of the tokens the server issues while the provider is on RS512.
Code Review ✅ Approved 🔴 High risk 2 closed / 2 findingsChanging SSO authentication, JWT verification, and security-configuration rollback could reject valid users or leave administrators with unintended access settings. Makes SSO failures recoverable: failed OIDC sign-ins return to the sign-in page with a reason, security-setting saves that the server cannot apply are refused with 400, OpenMetadata-issued tokens are signed with RS256 independent of the provider algorithm, and concurrent first SAML sign-ins share one account. Stale-token bot regeneration now treats legacy RS384/RS512 tokens as stale, and the accepted MCP discovery ADR was updated to match the server's own signing algorithm. No open issues found. ✅ 2 closed✅ Bug: Stale-token bot regeneration treats legacy RS384/RS512 tokens as stale
✅ Quality: Accepted MCP discovery ADR still says alg = tokenValidationAlgorithm
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. 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 OSS issue tracks these defects yet: they come from the SSO row of 2.1.0 release testing (codes below are that page's), found by the
Sso*ITmock identity-provider suite. Refs #35799.One commit per area:
tokenValidationAlgorithmno longer breaks bot, personal access and session tokens. The server signs its own tokens with RS256; the setting applies to the provider's tokens only.Out of scope:
Needs a 2.1 backport after review.
Type of change:
High-level design:
The rules are recorded in
docs/decisions/:2026-11-12-a-failed-sso-sign-in-returns-to-the-sign-in-page2026-11-12-openmetadata-signs-its-own-tokens-with-rs2562026-11-12-a-security-configuration-save-applies-in-full-or-is-refusedTests:
Use cases covered
The codes above, each as an integration test against the in-JVM mock identity providers.
Unit tests
AuthenticationCodeFlowHandlerTest,JwtFilterTest,JWTTokenGeneratorTest,SamlAuthServletHandlerTest,ConcurrentFirstOidcLoginTest, newSystemRepositorySecurityConfigPatchTestandLdapUtilTest; UI:SignInPage.test.tsx.Backend integration tests
SsoOidcConfidentialLoginIT,SsoOidcPublicBearerIT,SsoSamlLoginIT, newSsoSecurityConfigApplyIT.Sso*ITclasses,SystemResourceIT,McpOAuthIT,ConfigResourceITandOpsRegenerateBotTokensIT(185 tests), thenSsoSamlLoginITandSsoSecurityConfigApplyITagain after the last change.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
None against a real identity provider; the release-testing plan covers that.
UI screen recording:
Not applicable — a bug fix that adds an error message to the sign-in page, covered by Jest.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.docs/decisions/.🤖 Generated with Claude Code
Review follow-up (2026-11-14)
Preserve valid RS256, RS384 and RS512 bot tokens in stale-only regeneration using the same own-token verifier as request authentication. Unsigned and HMAC tokens are rejected. Added signed-token regressions. Focused unit run: 446 tests passed; sign-in UI: 18 tests passed.
Fresh MySQL + Elasticsearch integration run: 46 tests passed across SsoSecurityConfigApplyIT (5), SsoOidcPublicBearerIT (14), SsoSamlLoginIT (8), and SsoOidcConfidentialLoginIT (19). This is focused validation, not the full merge-gating suite.


Confidence Score: 5/5
The follow-up appears safe to merge; all three previous findings are addressed.Summary
This PR gives failed SSO sign-ins clear messages, keeps server-issued tokens independent of provider signing settings, and refuses security settings the server cannot apply.
Review checks were based on source and test inspection; no tests were run during this review.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Admin saves security settings] --> B[Check settings] B --> C[Write only if stored rows still match] C -->|Another save won| D[Keep newer save and return 412] C --> E[Reload authentication] E -->|Success| F[Return success] E -->|Failure| G[Restore previous rows only if they still match this save] G -->|Restored| H[Return 400 with reason] G -->|Another save won| D G -->|Restore failed| I[Return 500 with warning]Reviews (2) · Last reviewed commit: "docs(adr): amend MCP discovery to advert..." · Reviewed by Greptile