Repository navigation
[2.0] Fixes 28619: Accept Okta SAML certificates whose CN is the org name - #33625
Conversation
…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)
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ Playwright Results — workflow succeededValidated commit ✅ 1064 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking 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:
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) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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!
| const errors = (await (await validateResponse).json())?.errors ?? []; | ||
| const certificateError = errors.find( | ||
| (error: { field: string }) => error.field === IDP_CERT_FIELD_PATH |
There was a problem hiding this comment.
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!
| if (nullOrEmpty(certCN)) { | ||
| LOG.warn("IdP certificate has no Common Name (CN) in its subject"); | ||
| return; |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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.
| .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) { |
There was a problem hiding this comment.
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!
|
|



Automated backport of #33446 to
2.0.50a815e7c12f29804e4199253bcadb4d8ea05417main.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
The outstanding repository requirements must be met before merging.
Findings
Summary
This PR lets administrators save SAML certificates whose names differ from the identity provider’s address.
Reviews (3) · Last reviewed commit: "Merge branch '2.0' into backport/2.0/pr-..." · Reviewed by Greptile