Skip to content

Fixes #37056: Sign the SAML configuration check and show the IdP's error reason (backport 2.0 #37436) - #37437

Merged
mohityadav766 merged 4 commits into
2.0from
fix/37056-saml-signed-probe-2.0
Nov 11, 2026
Merged

mohityadav766 merged 4 commits into
2.0from
fix/37056-saml-signed-probe-2.0

Conversation

@mohityadav766

@mohityadav766 mohityadav766 commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

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:

  1. never signed the request, even with Send Signed Auth Request on. A Microsoft Entra application that requires signed requests answers 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;
  2. hid the IdP's reason. It read 500 bytes and showed SSO URL returned error (HTTP 400). Please verify the URL is correct., while Entra's AADSTS message sits in the page's $Config script, past byte 500.

What changes, as in #37436:

  • 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.
  • An Entra rejection carries Entra's reason, read by the new IdpErrorResponse from strServiceExceptionMessage.
  • A 4xx whose first bytes mention "saml" or "invalid" no longer passes as a warning.
  • An SP private key OneLogin cannot load is reported on the SP private key field.

What differs from #37436 on 2.0:

  • SamlSettingsHolder.buildSettings does not exist on 2.0 (Fixes #28784: Interactive Test Login round-trip for SSO configuration #34054 added it on main). It is extracted from initDefaultSettings the same way, and it closes the keystore stream it opens (Fixes 27091: Close SAML validation resources #34082 did that on main), because the check now loads the keystore on every validation. The new SamlSettingsHolderTest pins that initDefaultSettings still installs the live settings.
  • 2.0 has no outbound-URL gate (isProbeAllowed) or openConnection seam; those came with main-only security hardening. The connection code keeps 2.0's shape, and an SSO URL that is not HTTP stays a warning, as before.
  • Without that gate, the SSO Login URL can name any address the server reaches. So only a reason in Entra's own error format goes back in the field error. For any other page, the field error gives the HTTP status and says the response is in the server log, where the start of the page's text (at most 300 characters) is logged at WARN. main shows that text in the field error, because its URL policy decides which servers the check may reach.
  • Left out: the decision records under docs/decisions/, which are main-only; the Javadoc states the rules inline.
  • [2.0] Fixes 28619: Accept Okta SAML certificates whose CN is the org name #33625 (the automated 2.0 backport of Fixes 28619: Accept Okta SAML certificates whose CN is the org name #33446) edits the same two files, in the imports and the certificate-naming section. Whichever merges second resolves the imports.

Login (ACS). The same Entra setup hid a second reason. When java-saml rejected a posted response, the ACS threw SAML authentication failed before reading java-saml's reason, so the browser got {"error":"SAML authentication failed"}. The branch meant to report getLastErrorReason() could never run, because java-saml records errors only when it does not authenticate.

  • The login now fails with 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 answers SAML response rejected: The Message of the Response is not signed and the SP requires it.
  • On 2.0 this is a private check in SamlAuthServletHandler; main puts it in SamlResponseValidator, 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:

  • Want Messages Signed and Want Assertions Signed are separate switches, but java-saml checks them only in strict mode, so with Strict Mode off they did nothing. The form now shows them only while Strict Mode is on (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.
  • Enforcing the two switches without Strict Mode was in an earlier commit of this PR and is reverted, as on Fixes #37056: Sign the SAML configuration check and show the IdP's error reason #37436. In a patch release it would stop a working login wherever the IdP does not sign the element a switch names, and with SAML as the only login the admin could not reach the form to turn the switch off.
  • The SP certificate and key from the form reached java-saml only when Send Signed Auth Request (or the hidden Want Assertion Encrypted) was on. Entra encrypts assertions once token encryption is on, so with request signing off the assertion could not be decrypted. They now go to java-saml whenever they are filled in; the keystore is still read only when signing or encryption needs it.
  • The decision record ADR:2026-11-10-saml-security-settings-mean-what-the-form-shows is on main (Fixes #37056: Sign the SAML configuration check and show the IdP's error reason #37436).

Type of change:

  • Bug fix

High-level design:

N/A — small change, a backport of #37436.

Tests:

Use cases covered

  • Strict Mode off: the SAML form hides Want Messages Signed and Want Assertions Signed. Turning Strict Mode on shows them.
  • SP key filled in with request signing off: java-saml gets the key, so assertions Entra encrypts can be decrypted.
  • Strict mode with signed messages wanted, and an IdP that signs only the assertion: the login fails with java-saml's reason, not SAML authentication failed.
  • Request signing on, and the IdP requires signed requests: validation passes, and the IdP verified the HTTP-Redirect signature with the SP certificate.
  • Request signing off, against the same IdP: the error carries AADSTS76021 instead of the generic text.
  • A server that is not Entra answers with an error page: the field error gives the HTTP status, and the page text stays out of it.
  • An SP private key OneLogin cannot load, and settings OneLogin cannot build: both reported, not passed.
  • 4xx and 5xx responses, an unreachable IdP and a non-HTTP SSO URL (both still warnings), Entra escaping.
  • initDefaultSettings installs the live configuration; buildSettings leaves it in place and reads the keystore with its password.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files:
    • SamlValidatorTest, including validateIdpConnectivityKeepsAnotherServersPageOutOfTheFieldError.
    • New IdpErrorResponseTest, including entraReasonOfReadsOnlyEntraErrorPages.
    • New SamlSettingsHolderTest, including buildSettingsGivesJavaSamlTheSpKeyWithoutRequestSigning.
    • 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".
  • RED on the unchanged 2.0 code: 9 tests failed, including expected: <… (HTTP 400): AADSTS76021: …> but was: <SSO URL returned error (HTTP 400). Please verify the URL is correct.>.
  • RED for the ACS on the unchanged handler: the new handler test failed (1 of 22), with {"error":"SAML authentication failed"} on the wire.
  • RED for the SP key on the unchanged SamlSettingsHolder: the SP-key test found getSPkey() null.
  • RED for the review fixes, each on the commit before it:
    • another server's page reached the field error: 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>;
    • the form test found both switches on a new SAML form with Strict Mode off.
  • GREEN:
    • backend: 105 passed: SamlValidatorTest 65, IdpErrorResponseTest 11, SamlAuthServletHandlerTest 22, SamlSettingsHolderTest 4, MockSamlIdpTest 3;
    • UI: jest src/components/SettingsSso: 118 passed in 7 suites.
  • Coverage on changed lines (JaCoCo, same run): 132/132 changed executable lines (100%): SamlValidator 72/72, SamlSettingsHolder 31/31, IdpErrorResponse 23/23, SamlAuthServletHandler 6/6.

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Updated playwright/e2e/Features/SSOConfiguration.spec.ts and playwright/constant/ssoConfiguration.ts:
    • the SAML field check no longer expects the two switches on a new form;
    • the new test "should show the SAML signing switches only while Strict Mode is on" checks that they are hidden, turns Strict Mode on, and checks that they are shown.
  • Not run locally; ESLint is clean on both files.

Manual testing performed

  1. Strict mode and Want Messages Signed on, behind Entra's default signing (assertion only): the login answered {"error":"SAML authentication failed"}, while the server log carried The Message of the Response is not signed and the SP requires it. With Want Messages Signed off, the same Entra application logged in.
  2. On 2.0.7, an Entra application that requires signed requests showed SSO URL returned error (HTTP 400). Please verify the URL is correct., while Entra's page carried AADSTS76021.
  3. A live Entra error page (unknown tenant, HTTP 400) has its reason at byte 1417, with &#39;-escaped quotes. IdpErrorResponseTest covers it.
  4. Pending: a signed check request against a real Entra application with a verification certificate.

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:

🤖 Generated with Claude Code

…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.
@mohityadav766
mohityadav766 requested a review from a team as a code owner November 9, 2026 17:59
@mohityadav766
mohityadav766 requested review from manerow and removed request for a team November 9, 2026 17:59
@mohityadav766 mohityadav766 self-assigned this Nov 9, 2026
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".
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

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.
Comment on lines +498 to +507
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);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, reverted in f2a953c. The ACS no longer applies the two switches, so 2.0.8 accepts the same responses as 2.0.7. As on #37436, the form now shows them only while Strict Mode is on.

Comment on lines +417 to +420
String message =
IdpErrorResponse.reasonOf(responseBody)
.map(reason -> outcome + ": " + reason)
.orElse(fallback);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@mohityadav766
mohityadav766 requested a review from a team as a code owner November 10, 2026 19:30
@mohityadav766
mohityadav766 requested review from karthicksharan and removed request for a team November 10, 2026 19:30
@gitar-bot

gitar-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown
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.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@mohityadav766
mohityadav766 merged commit 660ce15 into 2.0 Nov 11, 2026
69 of 79 checks passed
@mohityadav766
mohityadav766 deleted the fix/37056-saml-signed-probe-2.0 branch November 11, 2026 07:09
mohityadav766 added a commit that referenced this pull request Nov 30, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants