Skip to content

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

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

manerow merged 13 commits into
2.1from
fix/saml-idp-certificate-pem-migration-2.1

Conversation

@manerow

@manerow manerow commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #37056

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

#38197, #38219 and #38302 read the IdP certificate strictly: one on a single line, or with spaces for line breaks, stops the server at startup. We keep it; the database must hold only certificates it accepts:

  1. Existing data. A 2.0.10 migration rewrites samlConfiguration.idp.idpX509Certificate as standard PEM; an unreadable value stays, with a warning.
  2. New values, one check. Every settings write (security PUT and PATCH, settings API, update-security-config, seeds, reconcile) passes SystemRepository.prepareSettingForUpdate. That step now gets the decrypted stored value 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 and surfaces as before: 400, exit 1, a stopped first or ENV start, or a kept value and error log in AUTO/DB. SettingsWriteFunnelTest fails if a new method writes a setting past that step. Undoing a security save the server cannot apply puts back the rows it replaced as they were read, without the check, so a stored certificate that has since expired comes back.

Release note (next 2.1 patch): OpenMetadata now reads the SAML IdP certificate strictly as standard PEM; a certificate saved in the database is rewritten during the upgrade. Before upgrading with SECURITY_CONFIG_SOURCE=ENV, change a single-line SAML_IDP_CERTIFICATE that includes the BEGIN and END lines to the certificate's base64 body alone, on one line without those lines, or the server does not start. Standard PEM works only when written in the configuration file, not in the variable. In the default AUTO mode a later change to the variable is not applied over the migrated value; apply it with adopt-deployment-config or ENV mode. 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.

#38302 merges cleanly with this branch.

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: SystemRepositorySecuritySettingsTest; what update-security-config stores: OpenMetadataOperationsSecurityConfigTest; undoing a refused save over an expired certificate: SystemResourceSecurityConfigApplyTest; also DeploymentConfigReconcilerTest, SettingsWriteFunnelTest. 291 tests pass on this branch.

Backend integration tests

  • SsoSamlIdpCertificateIT: PUT and PATCH refuse a bad certificate (400, nothing stored), store a good one, keep a stored expired one, and put it back unchanged when a save cannot be applied. Also green: SsoSecurityConfigApplyIT; on the previous head, SamlSecurityConfigIT, ConfigSourceIT and two more.

Manual testing performed

Real runs on main (same code; MySQL, PostgreSQL): a bad certificate stops a fresh install and ENV; AUTO keeps the row; update-security-config exits 1 and writes 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; neither numbered previous finding remains outstanding.

Summary

The PR repairs older stored SAML certificates and checks new certificates before settings reach the database.

  • The 2.0.10 upgrade rewrites readable stored SAML certificates as standard PEM.
  • New or changed SAML certificates must pass a shared check before settings are saved.
  • A refused security save restores the exact settings it replaced.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Settings write] --> B{New or changed SAML certificate?}
  B -->|No| E[Store settings]
  B -->|Yes| C[Check certificate]
  C -->|Accepted| E
  C -->|Refused| D[Return error without storing]
Loading

Reviews (17) · 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 TeddyCr 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

Rewriting stored SAML IdP certificates and gating security-setting writes changes the authentication boundary; rejected or malformed values could disrupt SAML login or startup.

Adds a 2.0.10 migration that rewrites stored SAML IdP certificates as standard PEM and validates new or changed certificates in the shared settings write step before they are saved. A refused security save restores the rows it replaced. 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

@manerow
manerow merged commit 48dc7df into 2.1 Nov 23, 2026
56 of 58 checks passed
@manerow
manerow deleted the fix/saml-idp-certificate-pem-migration-2.1 branch November 23, 2026 15:51
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