Skip to content

[2.0] Fixes #37056: Rewrite the stored SAML IdP certificate as standard PEM in the 2.0.10 migration - #38317

Merged
manerow merged 10 commits into
2.0from
fix/saml-idp-certificate-pem-migration-2.0
Nov 23, 2026
Merged

manerow merged 10 commits into
2.0from
fix/saml-idp-certificate-pem-migration-2.0

Conversation

@manerow

@manerow manerow commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #37056

Backport of #38315 to 2.0. 2.1 backport: #38318.

#38197 put the strict SAML certificate reader on 2.0: a certificate on one line, or with spaces for line breaks, now stops the server at startup. 2.0.10 is not tagged yet, so this should land before it. We keep the strict reader; the database must hold only certificates it accepts:

  1. Existing data. A 2.0.10 migration rewrites samlConfiguration.idp.idpX509Certificate as standard PEM (read the way 2.0.9 did, order kept, no duplicates); an unreadable value stays, with a warning.
  2. New values, one check. 2.0 has the same write step as main: every settings write (security PUT and PATCH, the settings API, update-security-config, the first-start seed through createNewSetting) passes SystemRepository.prepareSettingForUpdate. That step now gets the stored value it replaces and runs SamlValidator.validateIdpCertificate, the UI save rule, only on a new or changed certificate: an unchanged expired one is never refused. A refusal stores nothing: 400 from the API, exit 1 from the command, a stopped first start.

Differences from main: 2.0 has no deployment reconciler or ENV mode, and stores the authentication configuration unencrypted, so the step compares the stored value as is. 2.0 has no ArchUnit, so the guard test SettingsWriteFunnelTest is main and 2.1 only. The 2.0.10 folder already exists (#38301).

Release note (2.0.10): The SAML IdP certificate is now read strictly as standard PEM. A stored certificate is rewritten during the upgrade, so upgrades need nothing. On a new installation, give SAML_IDP_CERTIFICATE as the certificate's base64 body alone, on one line, without the BEGIN and END lines; a single line that includes them is refused and the server does not start. Standard PEM works only when written in the configuration file, not in the variable. Saving a new or changed IdP certificate that the server cannot read, from the settings page, the API or update-security-config, is now refused with an error instead of being stored.

Related, not in this PR: 2.0 still stops when every IdP certificate has expired (parseUnexpiredIdpCertificates); #38219 / #38302 fix that.

Type of change:

  • Bug fix

High-level design:

None.

Tests:

Unit tests

  • Migration: IdpCertificatePemTest, SamlIdpCertificateMigrationTest (MySQL 8.3, PostgreSQL 16).
  • Each write path, bad, good and unchanged expired: SystemRepositoryIdpCertificateTest; also SettingsCacheAuthenticationSeedTest, OpenMetadataOperationsSecurityConfigTest. 182 tests pass.

Backend integration tests

  • SamlIdpCertificatePutIT: PUT and PATCH refuse a bad certificate and store nothing; a good one is stored; a stored expired one is not refused by the check (2.0's runtime still refuses an all-expired IdP). Also green: SystemResourceIT, SamlSecurityConfigIT.

Manual testing performed

Real runs, MySQL and PostgreSQL: migrate from 2.0.9 rewrote a single-line certificate and a 2.0.10 server then started; a fresh install with a single-line variable stops and stores nothing.

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.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md; no 🔴 finding.
  • Decision check: updates docs/decisions/2026-11-20-the-stored-saml-idp-certificate-is-standard-pem.md.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new blocking issue was found.

Summary

Rewrites older stored SAML IdP certificates as standard PEM during the 2.0.10 migration and checks new or changed certificates before settings are stored.

  • The 2.0.10 upgrade rewrites older SAML certificates as standard PEM.
  • Settings writes reject unusable new SAML IdP certificates.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Settings write] --> B{Certificate changed?}
  B -->|No| E[Store setting]
  B -->|Yes| C[Check certificate]
  C -->|Accepted| E
  C -->|Refused| D[Reject without storing]
  F[2.0.10 migration] --> G[Rewrite readable older layouts as PEM]
  G --> H[(Stored authentication settings)]
  E --> H
Loading

Reviews (16) · Last reviewed commit: "Check a whitespace-only SAML IdP certifi..." · Reviewed by Greptile

@manerow
manerow requested a review from a team as a code owner November 20, 2026 14:36
@manerow
manerow requested review from mohityadav766 and removed request for a team November 20, 2026 14:36
@github-actions

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.

@gitar-bot

gitar-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 1 closed / 1 findings

Rewriting stored SAML IdP certificates and gating authentication-setting writes changes a login trust boundary; certificate refusal or parsing issues could disrupt SAML access.

Rewrites stored SAML IdP certificates as standard PEM during the 2.0.10 migration and checks new or changed certificates on every settings write path before they are stored. No issues found.

✅ 1 closed
Closed: Bug: Multi-catch of BadRequestException with its supertype won't compile

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SystemRepository.java:325 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SystemRepository.java:344 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SystemRepository.java:463 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/SystemRepository.java:485
SystemRepository imports org.openmetadata.service.exception.BadRequestException. That class extends WebServiceException, which extends jakarta.ws.rs.WebApplicationException. Java rejects a multi-catch whose alternatives are related by subclassing (JLS 14.20: "Alternatives in a multi-catch statement cannot be related by subclassing"), so catch (BadRequestException | WebApplicationException ex) is a compile error at all four places this commit adds it. The service module will not build.

WebApplicationException already covers the service BadRequestException, the jakarta.ws.rs.BadRequestException that SamlIdpCertificateGate throws, and PreconditionFailedException (a ClientErrorException). Catching WebApplicationException alone keeps the intended rethrow behaviour.

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

@manerow
manerow merged commit 8a796a4 into 2.0 Nov 23, 2026
89 of 94 checks passed
@manerow
manerow deleted the fix/saml-idp-certificate-pem-migration-2.0 branch November 23, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant