Repository navigation
Fixes #37056: Sign the SAML configuration check and show the IdP's error reason - #37436
Conversation
…ason The SAML validator checked the IdP SSO Login URL with a hand-built AuthnRequest that was never signed. It read the first 500 bytes of the reply, let a 4xx pass when those bytes mentioned "saml" or "invalid", and otherwise said "SSO URL returned error (HTTP 400). Please verify the URL is correct." A Microsoft Entra application that requires signed requests answers an unsigned request with AADSTS76021, so a configuration with Send Signed Auth Request on could not be saved, and Entra's reason, which sits in the page's $Config script past byte 500, was never shown. - The check sends the request the live login sends: OneLogin builds it from the candidate configuration with SamlSettingsHolder.buildSettings and signs it when request signing is on. - A rejection carries the IdP's own reason: Entra's AADSTS message from $Config, otherwise the page's visible text (IdpErrorResponse). - A 4xx that mentions "saml" or "invalid" no longer passes as a warning, since the check request is now the real one. - An SP private key OneLogin cannot load is reported on the SP private key field, because the live login cannot start with it either. - Recorded in ADR:2026-11-09-the-saml-configuration-check-sends-the-live-sign-in-request.
The ACS threw "SAML authentication failed" as soon as java-saml did not accept a response, before reading its reason, so the person signing in never learned the cause. The branch that was meant to report getLastErrorReason() could not run: java-saml only records errors when it does not authenticate. The login now fails with "SAML response rejected: <java-saml's reason>", as SamlResponseValidator already reports its own checks. For example, an SP in strict mode that wants signed messages, behind an Entra application that signs only the assertion, now answers "SAML response rejected: The Message of the Response is not signed and the SP requires it". SamlResponseValidator holds the acceptance check, which Test Login now shares instead of keeping its own copy.
|
✅ SSO Login Nightly — PASSED View workflow run · Commit
Totals: 94 passed · 0 failed · 0 flaky · 0 skipped · duration 18m 18s |
The settings form offers Want Messages Signed and Want Assertions Signed as switches of their own, but java-saml checks them only in strict mode, so with strict mode off they did nothing. SamlResponseValidator, which already applies java-saml's strict-only checks to every response, now also rejects a response whose Response or Assertion element lacks the signature the switch asks for, in java-saml's wording. The SP certificate and private key from the form reached java-saml only when the SP signed requests or required encrypted assertions, and the form hides the encryption switch. Microsoft Entra encrypts assertions once token encryption is on, so with request signing off the assertion could not be decrypted even though the key was filled in. The certificate and key now go to java-saml whenever they are configured; the keystore is still read only when signing or encryption needs it. Recorded in ADR:2026-11-10-saml-security-settings-mean-what-the-form-shows.
| private static void requireRequestedSignatures( | ||
| Saml2Settings settings, List<String> signedElements) { | ||
| if (settings.getWantMessagesSigned() && !signedElements.contains(SIGNED_RESPONSE)) { | ||
| throw rejected(UNSIGNED_MESSAGE); | ||
| } | ||
| if (settings.getWantAssertionsSigned() && !signedElements.contains(SIGNED_ASSERTION)) { | ||
| throw rejected(UNSIGNED_ASSERTION); | ||
| } | ||
| } |
There was a problem hiding this comment.
Turning these two switches on with Strict Mode off used to do nothing, and now it rejects the login. So a deployment that turned one on, behind an IdP that doesn't sign that element, stops logging in right after the upgrade. Keycloak's default client is one example: it signs the Response but not the Assertion, so with Want Assertions Signed on, every login fails with "The Assertion of the Response is not signed and the SP requires it".
If SAML is the only way to log in, the admin can't open the settings form to turn the switch off. The decision record covers the change, but the PR has nothing that reaches the people upgrading, like a release or upgrade note.
There was a problem hiding this comment.
Agreed, reverted in 70087c4. SamlResponseValidator no longer applies Want Messages Signed / Want Assertions Signed, so java-saml applies them only in strict mode, as before this PR, and no working login changes on upgrade. Instead the settings form shows the two switches only while Strict Mode is on, so it no longer offers a switch that does nothing; stored values are kept. The ADR now records that, and why enforcing them was rejected (your Keycloak example).
| if (!isProbeAllowed(samlConfig.getIdp().getSsoLoginUrl())) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
When the outbound URL policy refuses the SSO Login URL, validateIdpConnectivity returns before buildSignInUrl runs. So for an IdP on a private network, such as an on-premises ADFS, a configuration OneLogin can't turn into a sign-in request still saves. One example is Send Signed Auth Request on with a PKCS#1 SP key. The live login then fails on it, whatever the URL policy says. The decision record says a configuration like this fails the check. Gitar raised the same point and it's still open.
There was a problem hiding this comment.
Fixed in 70087c4. validateIdpConnectivity builds the sign-in request first and asks isProbeAllowed only before sending it. validateIdpConnectivityReportsAnUnusableSpKeyForAnIdpItMayNotProbe covers it: request signing with a PKCS#1 key, behind 169.254.169.254, gets the SP-key field error, and openConnection is never called.
…ng them The previous commit made Want Messages Signed and Want Assertions Signed hold with strict mode off. That would stop a working login on upgrade wherever the identity provider does not sign the element a switch names (Keycloak's default client signs the Response but not the Assertion), and an admin whose only login is SAML could not reach the form to turn the switch off. SamlResponseValidator no longer applies the two switches; java-saml applies them in strict mode, as before. The settings form now shows the two switches only while Strict Mode is on, so it no longer offers a switch that does nothing. Values stored while they are hidden are kept and take effect once Strict Mode is on. The SP certificate and key still go to java-saml whenever they are configured. The configuration check now builds the sign-in request before it asks the outbound URL policy whether it may send it. Building needs no network, so a configuration the live login cannot turn into a request, such as request signing with a PKCS#1 SP key, fails the check even for an identity provider on a private network that the policy does not let the server probe. ADR:2026-11-10-saml-security-settings-mean-what-the-form-shows is updated to match.
Code Review ✅ Approved 1 closed / 1 findings🔴 High risk · Enforcing SAML message and assertion signatures changes login acceptance and could lock users out when an IdP omits a configured signature. Makes the SAML configuration check sign its probe request when request signing is on and surface the IdP's rejection reason, and enforces Want Messages/Assertions Signed with or without Strict Mode. One resolved item: an unloadable SP private key no longer passes when the URL policy refuses the probe. No open issues remain. ✅ 1 closed✅ Edge Case: Unloadable SP key passes when the URL policy refuses the probe
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 |
…ror reason (backport 2.0 #37436) (#37437) * Fixes #37056: sign the SAML configuration check and show the IdP's reason The SAML validator checked the IdP SSO Login URL with a hand-built AuthnRequest that was never signed. It read the first 500 bytes of the reply, let a 4xx pass when those bytes mentioned "saml" or "invalid", and otherwise said "SSO URL returned error (HTTP 400). Please verify the URL is correct." A Microsoft Entra application that requires signed requests answers an unsigned request with AADSTS76021, so a configuration with Send Signed Auth Request on could not be saved, and Entra's reason, which sits in the page's $Config script past byte 500, was never shown. - The check sends the request the live login sends: OneLogin builds it from the candidate configuration and signs it when request signing is on. SamlSettingsHolder.buildSettings is extracted from initDefaultSettings for this, as on main, and closes the keystore stream it opens. - A rejection carries the IdP's own reason: Entra's AADSTS message from $Config, otherwise the page's visible text (IdpErrorResponse). - A 4xx that mentions "saml" or "invalid" no longer passes as a warning, since the check request is now the real one. - An SP private key OneLogin cannot load is reported on the SP private key field, because the live login cannot start with it either. * Show why java-saml rejected a SAML response at the ACS The ACS threw "SAML authentication failed" as soon as java-saml did not accept a response, before reading its reason, so the person signing in never learned the cause. The branch that was meant to report getLastErrorReason() could not run: java-saml only records errors when it does not authenticate. The login now fails with "SAML response rejected: <java-saml's reason>". For example, an SP in strict mode that wants signed messages, behind an Entra application that signs only the assertion, now answers "SAML response rejected: The Message of the Response is not signed and the SP requires it". * Make the SAML security switches mean what the settings form shows The settings form offers Want Messages Signed and Want Assertions Signed as switches of their own, but java-saml checks them only in strict mode, so with strict mode off they did nothing. The ACS now also rejects a response whose Response or Assertion element lacks the signature the switch asks for, in java-saml's wording, whether or not strict mode is on. The SP certificate and private key from the form reached java-saml only when the SP signed requests or required encrypted assertions, and the form hides the encryption switch. Microsoft Entra encrypts assertions once token encryption is on, so with request signing off the assertion could not be decrypted even though the key was filled in. The certificate and key now go to java-saml whenever they are configured; the keystore is still read only when signing or encryption needs it. * Show the SAML signing switches only in strict mode instead of enforcing them The previous commit made the ACS apply Want Messages Signed and Want Assertions Signed with strict mode off. In a patch release that would stop a working login wherever the identity provider does not sign the element a switch names, and an admin whose only login is SAML could not reach the form to turn the switch off. The ACS no longer applies the two switches; java-saml applies them in strict mode, as before. The settings form now shows the two switches only while Strict Mode is on, as on main. Values stored while they are hidden are kept and take effect once Strict Mode is on. The SP certificate and key still go to java-saml whenever they are configured. The Playwright check of the SAML form's fields moves the two switches to a test that turns Strict Mode on. 2.0 has no outbound URL policy in front of the configuration check, so its SSO Login URL can name any address the server reaches. The field error now carries only a reason in Microsoft Entra's own error format; for any other page it gives the HTTP status, and the page text goes to the server log.
…ion (#37741) * fix(sso): return a failed OIDC sign-in to the sign-in page with its reason 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 * fix(sso): keep the server's own tokens valid when the provider algorithm 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 * fix(sso): save SSO settings only when the server can apply them - 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 * fix(sso): handle concurrent first SAML sign-ins and posts that are no 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. * fix(sso): preserve valid legacy RSA bot tokens during stale rotation * fix(sso): accept SAML request signing with a keystore when saving 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. * test(sso): make the SAML keystore save case reach the put-back 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". * fix(sso): put a refused security save back only over itself, and report 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. * docs(adr): amend MCP discovery to advertise the server's own signing 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.
Describe your changes:
Fixes #37056
Saving or validating a SAML configuration checks the IdP SSO Login URL by sending it a sign-in request, and blocks the save when the IdP rejects it. That check had two problems, on 2.0.7 and on
mainalike:AADSTS76021: The request sent by client is not signed while the application requires signed requests, so a configuration that does sign could not be saved. This is the SAML config: “SSO URL returned error (HTTP 400)” on Entra IdP SSO Login URL when signed-request options are enabled #37056 scenario.SSO URL returned error (HTTP 400). Please verify the URL is correct.Entra renders its error page from a$Configscript, so the AADSTS code sits past byte 500 (byte 1417 on a live AADSTS90002 page) and never reached the admin.What changes in
SamlValidator:SamlSettingsHolder.buildSettingsand signs it when request signing is on. Its RelayState isopenmetadata-configuration-check.IdpErrorResponsereads Entra'sstrServiceExceptionMessage(JSON- and HTML-unescaped), or for other IdPs the first 300 characters of the page's visible text. At most 64 KiB of the reply is read. For example:The identity provider rejected the SAML sign-in request (HTTP 400): AADSTS76021: The request sent by client is not signed while the application requires signed requests.BEGIN RSA PRIVATE KEY, is reported on the SP private key field. The live login could not start with it either. The request is built before the outbound URL policy is asked, so this also holds for an IdP the policy does not let the server probe, such as one on a private network; nothing is sent to it.isProbeAllowed) still decides whether the request is sent.The rule is recorded in
ADR:2026-11-09-the-saml-configuration-check-sends-the-live-sign-in-request. The 2.0 backport, for 2.0.8, is #37437.Login (ACS). The same Entra setup hid a second reason. When java-saml rejected a posted response, the ACS threw
SAML authentication failedbefore reading java-saml's reason, so the browser got{"error":"SAML authentication failed"}. The branch meant to reportgetLastErrorReason()could never run, because java-saml records errors only when it does not authenticate.SAML response rejected: <java-saml's reason>, the formSamlResponseValidatoralready uses for its own checks. An SP in strict mode that wants signed messages, behind an Entra application that signs only the assertion, now answersSAML response rejected: The Message of the Response is not signed and the SP requires it.SamlResponseValidator. Test Login shares it now instead of keeping its own copy.The settings form offers only the security switches that apply. Checking the form against the backend found two gaps:
useSsoConfiguration). The backend is unchanged: they still apply only in strict mode, so no login that works today stops working. Values stored while the switches are hidden are kept and apply once Strict Mode is on.ADR:2026-11-10-saml-security-settings-mean-what-the-form-shows.Type of change:
High-level design:
N/A — small change: one validator, one new helper class, one settings-form rule, tests and two decision records.
Tests:
Use cases covered
SAML authentication failed.AADSTS76021reason instead of the generic text.Unit tests
SamlValidatorTest: a fake IdP that verifies the signature, the Entra rejection reason, the unloadable SP key (validateIdpConnectivityReportsAnUnusableSpKeyForAnIdpItMayNotProbefor an IdP on a private network), the 4xx and 5xx reasons, the unreachable IdP.IdpErrorResponseTest.SamlAuthServletHandlerTest.handleCallback_showsWhyJavaSamlRejectedTheResponse: a strict SP that wants signed messages receives aMockSamlIdpresponse whose assertion alone is signed.SamlSettingsHolderTest(buildSettingsGivesJavaSamlTheSpKeyWithoutRequestSigning,buildSettingsReadsTheKeyStoreWithItsPassword).useSsoConfiguration.test.ts: "offers the SAML signing switches only while Strict Mode is on".mainvalidator: 10 tests failed, including:expected: <The identity provider rejected the SAML sign-in request (HTTP 400): AADSTS76021: …> but was: <SSO URL returned error (HTTP 400). Please verify the URL is correct.>expected: <null> but was: <FieldError[… error=SSO URL returned error (HTTP 400). Please verify the URL is correct.]>{"error":"SAML authentication failed"}on the wire.SamlSettingsHolder: the SP-key test foundgetSPkey()null.expected: not <null>;{"ui:hideError": true, "ui:widget": "hidden"}, received{"ui:title": "Want Messages Signed"}.SamlValidatorTest71,IdpErrorResponseTest10,SamlAuthServletHandlerTest26,SamlResponseValidatorTest5,TestLoginSamlHandlerTest4,MockSamlIdpTest3,SamlSettingsHolderTest3,SystemRepositorySecurityConfigValidationTest5 (mvn -o package -pl openmetadata-service -am -Dtest=...);jest src/components/SettingsSso: 210 passed in 12 suites.SamlValidator58/58,SamlSettingsHolder22/22,IdpErrorResponse20/20,SamlResponseValidator6/6,TestLoginSamlHandler3/3,SamlAuthServletHandler1/1.Backend integration tests
SamlSecurityConfigITand the SSO mock-IdP ITs post SAML configurations to/system/security/validateand/system/security/config. Their SSO Login URLs are.invalidhosts and request signing is off, so the check stays a connection warning there. They run in the merge queue.Ingestion integration tests
Playwright (UI) tests
main,SSOConfiguration.spec.tskeeps only the metadata-upload flow and does not check these switches. Thesettings-sso-samlvisual baseline ends at IdP Entity ID, above the security switches, so it does not change.make playwright_affectedreports impact-map gaps for the changed files, so the merge queue runs the full suite.Manual testing performed
{"error":"SAML authentication failed"}, while the server log carriedThe Message of the Response is not signed and the SP requires it. With Want Messages Signed off, the same Entra application logged in.SSO URL returned error (HTTP 400). Please verify the URL is correct.on the SSO Login URL field, while Entra's error page carriedAADSTS76021in its$Configscript.strServiceExceptionMessageat byte 1417, its quotes escaped as'.reasonOfDecodesHtmlEntitiesInTheEntraMessagecovers that page.login.microsoftonline.com/common/saml2. It answered HTTP 200 with the sign-in page, so the check passes there, as before.UI screen recording:
Not applicable — a standalone bug fix. The only UI change is that the SAML form hides Want Messages Signed and Want Assertions Signed while Strict Mode is off; the Jest test above covers both states.
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: not applicable, no schema changes.
For a UI feature or feature task: not applicable, a bug fix; see "UI screen recording".
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md. It led me to log only the message for request-building failures, drop a guard for an SSO URL basic validation already rejects, and remove a null check for a stream the contract never returns.Decision check:
docs/decisions/2026-11-09-the-saml-configuration-check-sends-the-live-sign-in-request.mdanddocs/decisions/2026-11-10-saml-security-settings-mean-what-the-form-shows.md.I have added a test that covers the exact scenario we are fixing (
validateSamlConfigurationSignsTheCheckRequestWhenRequestSigningIsOn,validateSamlConfigurationShowsTheIdpReasonWhenItRejectsAnUnsignedRequest).🤖 Generated with Claude Code