[PR #7185] feat(oauth-provider): cimd #7129

Open
opened 2026-03-13 13:25:08 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7185
Author: @dvanmali
Created: 1/7/2026
Status: 🔄 Open

Base: canaryHead: cimd


📝 Commits (2)

  • 57c67d0 feat: clientId metadata documents (CIMD)
  • 79e43db chore: pnpm-lock only

📊 Changes

16 files changed (+476 additions, -52 deletions)

View changed files

📝 .cspell/auth-terms.txt (+1 -0)
📝 demo/nextjs/lib/auth.ts (+3 -1)
📝 docs/content/docs/plugins/oauth-provider.mdx (+43 -4)
📝 packages/oauth-provider/package.json (+1 -0)
📝 packages/oauth-provider/src/metadata.ts (+6 -2)
📝 packages/oauth-provider/src/oauth.ts (+14 -34)
📝 packages/oauth-provider/src/oauthClient/index.ts (+25 -2)
📝 packages/oauth-provider/src/register.test.ts (+1 -1)
📝 packages/oauth-provider/src/register.ts (+3 -1)
📝 packages/oauth-provider/src/types/index.ts (+38 -4)
📝 packages/oauth-provider/src/types/oauth.ts (+54 -1)
📝 packages/oauth-provider/src/types/zod.ts (+20 -0)
packages/oauth-provider/src/utils/cimd.test.ts (+69 -0)
packages/oauth-provider/src/utils/cimd.ts (+140 -0)
📝 packages/oauth-provider/src/utils/index.ts (+49 -2)
📝 pnpm-lock.yaml (+9 -0)

📄 Description

Adds support for ClientId Metadata Documents as it has been added into the MCP protocol.

Deprecates: allowUnauthenticatedClientRegistration since insecure.

Demo:

https://github.com/user-attachments/assets/abee40ad-04a6-4ca4-915b-f3511b3fb73d

Closes: #7184


Summary by cubic

Adds Client ID Metadata Document (CIMD) support to the OAuth provider for secure unauthenticated dynamic client registration with automatic metadata fetch and periodic refresh. Deprecates allowUnauthenticatedClientRegistration and updates OIDC metadata and endpoints. Closes #7184.

  • New Features

    • CIMD config: enable, refreshRate (default 60m), restrictOrigins.
    • OIDC advertises client_id_metadata_document_supported; public_client_supported is true when CIMD is enabled.
    • Registration/admin endpoints accept HTTPS client_id; can create/update clients from CIMD; getClient auto-creates and refreshes on refreshRate.
    • Enforces HTTPS and same-origin for redirect_uris, post_logout_redirect_uris, and client_uri; blocks client_secret and shared-secret auth (client_secret_post/basic/jwt) for CIMD.
    • CIMD fetch rejects redirects and non-public hosts (DNS/IP check via ipaddr.js); adds HttpsOnlyUrl schema; registration schema aligned with RFC 7591 and shared across endpoints.
  • Migration

    • Replace allowUnauthenticatedClientRegistration with cimd.enable (now deprecated and warns).
    • Use HTTPS client_id URLs; ensure redirect URIs share origin when restrictOrigins is enabled.

Written for commit 79e43dbb4e3f57ecf17dd0976044d82db0eb7e00. Summary will update on new commits.


🔄 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/7185 **Author:** [@dvanmali](https://github.com/dvanmali) **Created:** 1/7/2026 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `cimd` --- ### 📝 Commits (2) - [`57c67d0`](https://github.com/better-auth/better-auth/commit/57c67d0162e7e3d07a5a16eeb9906c9951c6e338) feat: clientId metadata documents (CIMD) - [`79e43db`](https://github.com/better-auth/better-auth/commit/79e43dbb4e3f57ecf17dd0976044d82db0eb7e00) chore: pnpm-lock only ### 📊 Changes **16 files changed** (+476 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `.cspell/auth-terms.txt` (+1 -0) 📝 `demo/nextjs/lib/auth.ts` (+3 -1) 📝 `docs/content/docs/plugins/oauth-provider.mdx` (+43 -4) 📝 `packages/oauth-provider/package.json` (+1 -0) 📝 `packages/oauth-provider/src/metadata.ts` (+6 -2) 📝 `packages/oauth-provider/src/oauth.ts` (+14 -34) 📝 `packages/oauth-provider/src/oauthClient/index.ts` (+25 -2) 📝 `packages/oauth-provider/src/register.test.ts` (+1 -1) 📝 `packages/oauth-provider/src/register.ts` (+3 -1) 📝 `packages/oauth-provider/src/types/index.ts` (+38 -4) 📝 `packages/oauth-provider/src/types/oauth.ts` (+54 -1) 📝 `packages/oauth-provider/src/types/zod.ts` (+20 -0) ➕ `packages/oauth-provider/src/utils/cimd.test.ts` (+69 -0) ➕ `packages/oauth-provider/src/utils/cimd.ts` (+140 -0) 📝 `packages/oauth-provider/src/utils/index.ts` (+49 -2) 📝 `pnpm-lock.yaml` (+9 -0) </details> ### 📄 Description Adds support for ClientId Metadata Documents as it has been added into the [MCP protocol](https://modelcontextprotocol.io/specification/draft/basic/authorization#client-id-metadata-documents). **Deprecates**: `allowUnauthenticatedClientRegistration` since insecure. **Demo**: https://github.com/user-attachments/assets/abee40ad-04a6-4ca4-915b-f3511b3fb73d **Closes**: #7184 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds Client ID Metadata Document (CIMD) support to the OAuth provider for secure unauthenticated dynamic client registration with automatic metadata fetch and periodic refresh. Deprecates allowUnauthenticatedClientRegistration and updates OIDC metadata and endpoints. Closes #7184. - **New Features** - CIMD config: enable, refreshRate (default 60m), restrictOrigins. - OIDC advertises client_id_metadata_document_supported; public_client_supported is true when CIMD is enabled. - Registration/admin endpoints accept HTTPS client_id; can create/update clients from CIMD; getClient auto-creates and refreshes on refreshRate. - Enforces HTTPS and same-origin for redirect_uris, post_logout_redirect_uris, and client_uri; blocks client_secret and shared-secret auth (client_secret_post/basic/jwt) for CIMD. - CIMD fetch rejects redirects and non-public hosts (DNS/IP check via `ipaddr.js`); adds HttpsOnlyUrl schema; registration schema aligned with RFC 7591 and shared across endpoints. - **Migration** - Replace allowUnauthenticatedClientRegistration with cimd.enable (now deprecated and warns). - Use HTTPS client_id URLs; ensure redirect URIs share origin when restrictOrigins is enabled. <sup>Written for commit 79e43dbb4e3f57ecf17dd0976044d82db0eb7e00. Summary will update on new commits.</sup> <!-- 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 13:25:08 -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#7129