[PR #4858] [MERGED] fix(sso): safe json parsing for saml/oidc configs #5621

Closed
opened 2026-03-13 12:29:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4858
Author: @natetewelde
Created: 9/23/2025
Status: Merged
Merged: 10/1/2025
Merged by: @himself65

Base: canaryHead: fix(sso)-safe-json-parsing


📝 Commits (3)

  • 8478425 fix(sso): safe json parsing for saml/oidc configs
  • 614974c Merge branch 'canary' into fix(sso)-safe-json-parsing
  • 9a4ef8e chore: lint fix

📊 Changes

1 file changed (+70 additions, -14 deletions)

View changed files

📝 packages/sso/src/index.ts (+70 -14)

📄 Description

Summary by cubic

Make SAML and OIDC config parsing robust across DB/ORM returns to prevent crashes and provide clear errors. Replaces raw JSON.parse with a safe utility and adds checks in SSO flows.

  • Bug Fixes
    • Added safeJsonParse to handle strings, objects, or null (covers Drizzle returning parsed objects).
    • Replaced JSON.parse for samlConfig/oidcConfig and normalized undefined when absent.
    • Validated parsed SAML config; throw BAD_REQUEST for invalid config.
    • Made idpMetadata access optional with sensible fallbacks when metadata is missing.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4858 **Author:** [@natetewelde](https://github.com/natetewelde) **Created:** 9/23/2025 **Status:** ✅ Merged **Merged:** 10/1/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix(sso)-safe-json-parsing` --- ### 📝 Commits (3) - [`8478425`](https://github.com/better-auth/better-auth/commit/8478425a035d059b9c9cf3cfc08fb9d5bd1b4b72) fix(sso): safe json parsing for saml/oidc configs - [`614974c`](https://github.com/better-auth/better-auth/commit/614974c8800d852ca5df9ca263fa96ca414fb1a8) Merge branch 'canary' into fix(sso)-safe-json-parsing - [`9a4ef8e`](https://github.com/better-auth/better-auth/commit/9a4ef8e714635f3d36085eb3d99fe0c6ec8c8bb1) chore: lint fix ### 📊 Changes **1 file changed** (+70 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `packages/sso/src/index.ts` (+70 -14) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Make SAML and OIDC config parsing robust across DB/ORM returns to prevent crashes and provide clear errors. Replaces raw JSON.parse with a safe utility and adds checks in SSO flows. - **Bug Fixes** - Added safeJsonParse to handle strings, objects, or null (covers Drizzle returning parsed objects). - Replaced JSON.parse for samlConfig/oidcConfig and normalized undefined when absent. - Validated parsed SAML config; throw BAD_REQUEST for invalid config. - Made idpMetadata access optional with sensible fallbacks when metadata is missing. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:29:38 -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#5621