Skip to content

[2.0] Fixes 28619: Accept Okta SAML certificates whose CN is the org name - #33625

Merged
mohityadav766 merged 5 commits into
2.0from
backport/2.0/pr-33446
Nov 19, 2026
Merged

mohityadav766 merged 5 commits into
2.0from
backport/2.0/pr-33446

Conversation

@gh-bot-collate

@gh-bot-collate gh-bot-collate Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Automated backport of #33446 to 2.0.

Source PR #33446
Author @mohityadav766
Merge commit 50a815e7c12f29804e4199253bcadb4d8ea05417
Method Clean cherry-pick — identical to the commit on main.

Opened from openmetadata-collate, which holds the credentials needed to open a PR here. It merges itself once every check passes — no review needed. If a check fails it stays open and the author of #33446 is asked to look.

resolver run

RetriggerView in GreptileConfidence Score: 4/5

The outstanding repository requirements must be met before merging.

Findings

  1. P2 Null Bodies Return 500 ▶
  2. P2 Test Disables Concurrent Execution ▶
  3. P2 Rejected requests pass the test ▶
  4. P2 Helpers break required return style ▶
  5. P2 Unchanged values lack required final ▶
  6. P2 String checks lack required constants ▶
  7. P2 First-entry lookup breaks required style ▶
  8. P2 Exception names break required style ▶

Summary

This PR lets administrators save SAML certificates whose names differ from the identity provider’s address.

  • SAML setup accepts certificates whose names differ from the Entity ID.
  • Security settings check only the provider and client settings in use.

Reviews (3) · Last reviewed commit: "Merge branch '2.0' into backport/2.0/pr-..." · Reviewed by Greptile

…33446)

* Fixes 28619: Accept Okta SAML certificates whose CN is the org name

SamlValidator required the IdP certificate's CN to equal the Entity ID
host. Okta Entity IDs are always http://www.okta.com/{appId} — a format
validateBasicSamlConfig itself enforces — so the host is always the
literal www.okta.com, while Okta issues signing certificates with
CN=<org short name>. The branch was unsatisfiable, so every legitimate
Okta configuration was rejected on save. The only passing value was a CN
of literally *.okta.com, which Okta never issues and which was the sole
case the existing test covered.

The check had no security value: the certificate is a trust anchor taken
from the IdP's own metadata and handed to OneLogin's
IDP_X509CERT_PROPERTY_KEY, and SAML verifies signatures against its
public key without PKIX name validation, so the CN is never consulted.

The Auth0, Azure and non-Azure branches encoded the same assumption and
broke on Auth0 custom domains and on any change to Microsoft's
certificate naming, so all four collapse into the warn-and-continue path
that already existed for generic providers. A CN differing from the
Entity ID host logs at INFO — it is the expected shape for these
providers, so warning would train operators to ignore warnings. Parsing
and the validity window are still enforced.

Also scopes bean validation on PUT /system/security/config to the active
provider. @Valid cascaded into every nested block present, so an instance
carrying a partial ldapConfiguration could not save a SAML configuration
and a GET response was not accepted by PUT unchanged. Validation now runs
against a copy with inactive providers' blocks nulled, and
IllegalArgumentException is rethrown ahead of the blanket catch so an
invalid configuration answers 400 rather than 500.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Name the non-OIDC providers instead of listing the OIDC ones

The OIDC_PROVIDERS set duplicated the provider list that
SystemRepository.validateSecurityConfiguration already switches on, so
adding an OIDC provider meant editing two places. Invert it: name the
four providers that keep their settings outside oidcConfiguration and
let everything else default to it.

This only selects which config block to skip during bean validation. It
runs against a throwaway deep copy and never reads tokenValidity,
maxAge or sessionExpiry.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Address review findings on the #28619 SAML validation fix

Scope provider validation on the validate endpoint too, key the OIDC block
on clientType, and close the gaps the review found in the tests.

- POST /system/security/validate dropped @Valid and now runs the same
  provider-scoped validation as PUT. It is the first call the SSO form makes
  on save, so the inactive-block cascade still rejected the request there
  before PUT was ever reached.
- oidcConfiguration is not only the OIDC providers' block but the
  confidential client's, so clearing it now tests clientType alongside the
  usesOidcConfiguration check added in the previous commit. A partial block
  left behind by an earlier confidential setup no longer blocks a
  public-client save.
- Validation runs against the instance that is persisted rather than a
  Jackson deep copy. The round trip re-applied the schema defaults
  jsonschema2pojo emits as field initializers, leaving a @NotNull field that
  has a default unenforced on the object actually saved — `provider` is
  @NotNull and defaults to `basic`, so a payload sending it as null was
  accepted and stored.
- Narrowed the rethrow to BadRequestException, so a failure from the writes
  that follow is not reported to the admin as a 400.
- SamlValidator guards a null Entity ID instead of relying on an NPE into a
  catch-all.
- The Playwright route stubs only the PUT; the page's own GET reaches the
  server again, which enableSSOEditMode branches on.
- SamlSecurityConfigIT restores the configuration in a finally in the
  active-provider rejection test, covers the saml and oidc scoping branches,
  stops destroying the LDAP password its restore depends on, and uses an
  Auth0 certificate in the Auth0 custom-domain test.
- Jest covers a line-wrapped certificate, the shape real Okta metadata
  publishes.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
(cherry picked from commit 50a815e)
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit ca48d6d26bbc5182f2b4d45c36dfbeab2441642e in Playwright run 37023235107, attempt 1.

✅ 1064 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking 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 21s

⏱️ Max setup 3m 26s · max shard execution 18m 45s · max shard-job elapsed before upload 22m 4s · reporting 7s

🌐 208.16 requests/attempt · 2.43 app boots/UI scenario · 27.47% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 27.47% (convergence target: at most 15%).
  • Browser traffic was 208.16 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.43 per UI scenario (2923 boots / 1205 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 157 0 0 0 0 0
✅ Shard chromium-02 156 0 0 0 0 0
✅ Shard chromium-03 152 0 0 0 0 0
✅ Shard chromium-04 127 0 0 0 0 0
✅ Shard chromium-05 133 0 0 0 0 0
✅ Shard chromium-06 181 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@Context UriInfo uriInfo,
@Context SecurityContext securityContext,
@Valid SecurityConfiguration securityConfig) {
SecurityConfiguration securityConfig) {

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.

P2 Null Bodies Return 500

Removing @Valid leaves null request bodies outside the replacement validator. The PUT endpoint dereferences securityConfig at line 942, while the validation endpoint does so at line 993, causing an HTTP 500 instead of rejecting the malformed admin request with a 400. Add an explicit null check or retain request-boundary validation while limiting validation of nested provider blocks.

Knowledge Base Used: Service API resources

* the configuration it read in a {@code finally}, including on the paths where the assertion itself
* fails.
*/
@Execution(ExecutionMode.SAME_THREAD)

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.

P2 Test Disables Concurrent Execution

This new integration-test class uses ExecutionMode.SAME_THREAD, but the repository requires backend integration tests to be designed for concurrent execution and use @Execution(ExecutionMode.CONCURRENT). The tests need to avoid shared security-configuration mutations or isolate that state through the test infrastructure so this repository requirement can be satisfied before merging.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 68%
68.31% (82921/121375) 53.22% (51363/96509) 53.96% (15278/28309)

Comment on lines +968 to +970
const errors = (await (await validateResponse).json())?.errors ?? [];
const certificateError = errors.find(
(error: { field: string }) => error.field === IDP_CERT_FIELD_PATH

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.

P2 Rejected requests pass the test

A 400 response from validateConfigurationOfActiveProvider contains an error message rather than errors. The ?? [] fallback makes this check pass even though the server rejected the request before checking the certificate. This leaves the browser test green while users cannot submit their Okta configuration.

Assert that the response succeeded and has the expected validation result before checking the certificate field.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +517 to +519
if (nullOrEmpty(certCN)) {
LOG.warn("IdP certificate has no Common Name (CN) in its subject");
return;

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.

P2 Helpers break required return style

The new naming helpers use early returns, contrary to the Java requirement: “One return statement per method, placed at the end.” The same issue appears in logSubjectAlternativeNames and logSubjectAlternativeName.

Use conditional blocks instead. This repository requirement must be satisfied before merging.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

String idpEntityId = samlConfig.getIdp().getEntityId();
String ssoLoginUrl = samlConfig.getIdp().getSsoLoginUrl();
private void inspectIdpCertificateNaming(X509Certificate cert, SamlSSOClientConfig samlConfig) {
String certCN = extractCNFromDN(cert.getSubjectDN().toString());

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.

P2 Unchanged values lack required final

New locals such as certCN and idpEntityId never change but are not final. The Java guide requires final on local variables and parameters that do not change. The same pattern appears in the new configuration checks and integration tests.

Apply final to these declarations before merging to meet the repository requirement.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


assertEquals("failed", response.get("status").asText(), "Validation response: " + response);
assertTrue(
fieldError(response, IDP_CERT_FIELD).contains("expired"),

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.

P2 String checks lack required constants

The new test uses "expired" directly in contains. The Java guide says, “Never use raw string literals in .equals(), .contains(), or switch cases.” The "ldapConfiguration" check has the same issue.

Define named constants for these checks before merging to meet the repository requirement.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

LOG.debug("IdP certificate has {} Subject Alternative Names", sanNames.size());
sanNames.stream()
.filter(san -> san.size() >= 2)
.filter(san -> DNS_AND_URI_SAN_TYPES.contains((Integer) san.get(0)))

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.

P2 First-entry lookup breaks required style

The new SAN check uses san.get(0), but the Java guide requires getFirst() instead of get(0) for lists. Use san.getFirst() here; the preceding size check already ensures that an entry exists. This repository requirement must be satisfied before merging.

Suggested change
.filter(san -> DNS_AND_URI_SAN_TYPES.contains((Integer) san.get(0)))
.filter(san -> DNS_AND_URI_SAN_TYPES.contains((Integer) san.getFirst()))

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


LOG.info("Validating certificate CN '{}' against IdP configuration", certCN);
inspectIdpCertificateNaming(cert, samlConfig);
} catch (RuntimeException e) {

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.

P2 Exception names break required style

The new catch blocks name their exception e, contrary to the Java directive: “No single-letter variables except in short lambdas or loop indices.” This also appears in the new CertificateParsingException catch and the new catch in SystemResource.java.

Use descriptive exception names before merging to meet the repository requirement.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@pmbrull
pmbrull requested a review from manerow November 3, 2026 15:13
@mohityadav766
mohityadav766 merged commit af30169 into 2.0 Nov 19, 2026
71 of 75 checks passed
@mohityadav766
mohityadav766 deleted the backport/2.0/pr-33446 branch November 19, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant