[PR #8805] feat(sso): support multiple IDP signing certificates #16472

Open
opened 2026-04-13 10:32:07 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8805

State: open
Merged: No


With SAML IDPs, the metadata.xml document is live - they can rotate certificates.

When rotating certificates, there is a time when the metadata will reference signing certificates - BA currently only supports an IDP having a single signing cert, but the underlying library (samlify) does, so simply need to update the types & parsing.

This PR:

  • Adds the string[] type to certs
  • Adds tests for the parsing of multiple certs

Summary by cubic

Adds support for multiple IdP signing certificates in SAML SSO to handle certificate rotation. Accepts one or many certs, validates non-empty arrays, and returns clear errors.

  • New Features

    • SAMLConfig.cert and SAMLConfig.idpMetadata.cert now accept string | string[] (schema enforces non-empty arrays).
    • Provider read endpoint normalizes input, parses all certs, and returns samlConfig.certificate as an object for a single cert or an array for multiple; returns { error: "No certificates provided" } or { error: "Failed to parse certificate" } on errors. Tests cover multi/single parsing, SHA-256 fingerprints, and object-vs-array shape.
  • Migration

    • No changes needed for existing single-cert configs.
    • Clients should handle samlConfig.certificate being an object or an array.

Written for commit 9b201ab2da. Summary will update on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8805 **State:** open **Merged:** No --- With SAML IDPs, the metadata.xml document is live - they can rotate certificates. When rotating certificates, there is a time when the metadata will reference signing certificates - BA currently only supports an IDP having a single signing cert, but the underlying library (samlify) does, so simply need to update the types & parsing. This PR: - Adds the `string[]` type to certs - Adds tests for the parsing of multiple certs <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds support for multiple IdP signing certificates in SAML SSO to handle certificate rotation. Accepts one or many certs, validates non-empty arrays, and returns clear errors. - **New Features** - `SAMLConfig.cert` and `SAMLConfig.idpMetadata.cert` now accept `string | string[]` (schema enforces non-empty arrays). - Provider read endpoint normalizes input, parses all certs, and returns `samlConfig.certificate` as an object for a single cert or an array for multiple; returns `{ error: "No certificates provided" }` or `{ error: "Failed to parse certificate" }` on errors. Tests cover multi/single parsing, SHA-256 fingerprints, and object-vs-array shape. - **Migration** - No changes needed for existing single-cert configs. - Clients should handle `samlConfig.certificate` being an object or an array. <sup>Written for commit 9b201ab2da3a28b4970c5f91df27fa7b921d4a32. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 10:32:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16472