Repository navigation
Fixes #37056: Sign the SAML configuration check and show the IdP's error reason (backport 2.0 #37436) - #37437
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 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.
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".
❌ 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 |
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.
| private static void requireRequestedSignatures(Saml2Settings settings, SamlResponse response) | ||
| throws XPathExpressionException, ValidationError { | ||
| List<String> signedElements = response.processSignedElements(); | ||
| if (settings.getWantMessagesSigned() && !signedElements.contains(SIGNED_RESPONSE)) { | ||
| throw new AuthenticationException("SAML response rejected: " + UNSIGNED_MESSAGE); | ||
| } | ||
| if (settings.getWantAssertionsSigned() && !signedElements.contains(SIGNED_ASSERTION)) { | ||
| throw new AuthenticationException("SAML response rejected: " + UNSIGNED_ASSERTION); | ||
| } | ||
| } |
There was a problem hiding this comment.
This brings the same login behaviour change into 2.0.8, a patch release: with Strict Mode off, a deployment that has Want Messages Signed or Want Assertions Signed on, behind an IdP that doesn't sign that element, stops logging in after the patch upgrade. If SAML is the only login, the admin can't open the settings form to turn the switch off. #37056 doesn't need this part: the signed check and the IdP's error reason fix it without changing which responses the ACS accepts.
| String message = | ||
| IdpErrorResponse.reasonOf(responseBody) | ||
| .map(reason -> outcome + ": " + reason) | ||
| .orElse(fallback); |
There was a problem hiding this comment.
The configuration check now puts up to 300 characters of the reply's page text into the field error, for any non-2xx/3xx answer other than 404/405. On main, isProbeAllowed gates the request, but 2.0 doesn't have that gate. So on 2.0 an admin can point the SSO Login URL at a server-side address and get the start of its error page back in the save response. Before, the check only gave back the HTTP status.
There was a problem hiding this comment.
Fixed in f2a953c. Only a reason in Entra's own error format (strServiceExceptionMessage) goes into the field error now. For any other page, the field error gives the HTTP status and says the response is in the server log; the page text, at most 300 characters on one line, is logged at WARN. Covered by validateIdpConnectivityKeepsAnotherServersPageOutOfTheFieldError and entraReasonOfReadsOnlyEntraErrorPages.
…ng 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.
Code Review ✅ Approved🔴 High risk · Changing SAML signature enforcement and SP credential loading could deny legitimate logins or change which identity-provider responses are accepted. Fixes SAML configuration validation so the IdP check sends the same signed sign-in request the live login uses, and surfaces the IdP's own error reason instead of a generic message. Also rejects logins whose required message or assertion signatures are missing, and passes the SP key to java-saml whenever it is configured. No issues found. 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 |
…ng proxy (backport 2.0 #39255) (#39257) With Strict Mode on, java-saml compares a response's Destination and the Recipient of its bearer SubjectConfirmationData with the URL the request arrived on. When TLS ends at a load balancer, the server sees the identity provider's post to the https ACS arrive over http, so every response was rejected ("The response was received at http://... instead of https://..."), on the live login and on Test Login. Both paths now have java-saml compare with the configured ACS URL, the URL SamlResponseValidator already compares Destination with outside strict mode. A response addressed to any other URL is still rejected. 2.0's Test Login already installs a response factory that checks the response answers its request, so atConfiguredAcs wraps that factory's response. The decision record cites #37437 in place of a record 2.0 does not have. ADR:2026-11-27-saml-strict-mode-checks-the-configured-acs-url
Describe your changes:
Fixes #37056
Backport of #37436 to
2.0, so 2.0.8 gets the fix. 2.0.7 is where #37056 was reported.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. On 2.0.7 that check:
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;SSO URL returned error (HTTP 400). Please verify the URL is correct., while Entra's AADSTS message sits in the page's$Configscript, past byte 500.What changes, as in #37436:
SamlSettingsHolder.buildSettingsand signs it when request signing is on.IdpErrorResponsefromstrServiceExceptionMessage.What differs from #37436 on 2.0:
SamlSettingsHolder.buildSettingsdoes not exist on 2.0 (Fixes #28784: Interactive Test Login round-trip for SSO configuration #34054 added it onmain). It is extracted frominitDefaultSettingsthe same way, and it closes the keystore stream it opens (Fixes 27091: Close SAML validation resources #34082 did that onmain), because the check now loads the keystore on every validation. The newSamlSettingsHolderTestpins thatinitDefaultSettingsstill installs the live settings.isProbeAllowed) oropenConnectionseam; those came withmain-only security hardening. The connection code keeps 2.0's shape, and an SSO URL that is not HTTP stays a warning, as before.mainshows that text in the field error, because its URL policy decides which servers the check may reach.docs/decisions/, which aremain-only; the Javadoc states the rules inline.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>. 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.SamlAuthServletHandler;mainputs it inSamlResponseValidator, which 2.0 does not have.The settings form offers only the security switches that apply. Checking the form against the backend found two gaps:
SSOConfigurationForm). The backend is unchanged: they still apply only in strict mode, so no login that works today stops working after the patch upgrade. 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-showsis onmain(Fixes #37056: Sign the SAML configuration check and show the IdP's error reason #37436).Type of change:
High-level design:
N/A — small change, a backport of #37436.
Tests:
Use cases covered
SAML authentication failed.AADSTS76021instead of the generic text.initDefaultSettingsinstalls the live configuration;buildSettingsleaves it in place and reads the keystore with its password.Unit tests
SamlValidatorTest, includingvalidateIdpConnectivityKeepsAnotherServersPageOutOfTheFieldError.IdpErrorResponseTest, includingentraReasonOfReadsOnlyEntraErrorPages.SamlSettingsHolderTest, includingbuildSettingsGivesJavaSamlTheSpKeyWithoutRequestSigning.SamlAuthServletHandlerTest.handleCallback_showsWhyJavaSamlRejectedTheResponse.SSOConfigurationForm.test.tsx: "should hide the SAML signing switches while Strict Mode is off", "should show the SAML signing switches while Strict Mode is on".expected: <… (HTTP 400): AADSTS76021: …> but was: <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.but was: <The identity provider rejected the SAML sign-in request (HTTP 400): internal-only page text>, and for a 503,but was: <SSO URL is not accessible (HTTP 503): unavailable>;SamlValidatorTest65,IdpErrorResponseTest11,SamlAuthServletHandlerTest22,SamlSettingsHolderTest4,MockSamlIdpTest3;jest src/components/SettingsSso: 118 passed in 7 suites.SamlValidator72/72,SamlSettingsHolder31/31,IdpErrorResponse23/23,SamlAuthServletHandler6/6.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
playwright/e2e/Features/SSOConfiguration.spec.tsandplaywright/constant/ssoConfiguration.ts: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., while Entra's page carriedAADSTS76021.'-escaped quotes.IdpErrorResponseTestcovers it.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 and Playwright tests above cover 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 against
REVIEW.md, as on Fixes #37056: Sign the SAML configuration check and show the IdP's error reason #37436.Decision check: the records are on
main(Fixes #37056: Sign the SAML configuration check and show the IdP's error reason #37436); this backport states the rules inline.I have added a test that covers the exact scenario we are fixing.
🤖 Generated with Claude Code