Skip to content

OAuth AS facade phase 3: CIMD — accept https:// client_id metadata documents #5

Description

@selic

What

Third (final) phase of docs/plans/oauth-authorization-server.md. Phases 1+2 (DCR + authorize/token + gateway JWTs, rotating refresh tokens, admin client management) shipped in v0.4.0/v0.5.0 and are verified in prod.

CIMD (Client ID Metadata Documents) — the client registration mechanism the MCP spec (revision 2025-11-25) recommends: instead of registering via RFC 7591 DCR and receiving a server-issued client_id, the client identifies itself with an HTTPS URL pointing to a JSON metadata document (redirect_uris, client_name, …). The AS fetches and validates that document itself.

Fixes DCR's structural downsides, already visible in our admin UI after one day in prod:

  • client rows accumulate forever (every claude mcp add / device = a new row)
  • client identity is self-asserted (client_name: "Claude Code" proves nothing; a client_id under https://claude.ai/… does)
  • the anonymous register endpoint needs rate-limiting; CIMD has no registration step at all

Scope (additive on top of DCR — DCR stays as fallback)

  1. /oauth/authorize: when client_id is an https:// URL → fetch the metadata document (cached), validate redirect_uri against the document's redirect_uris, skip the oauth_clients table entirely.
  2. /oauth/token: codes and refresh tokens already bind to the client_id string — the URL just flows through; no schema migration expected.
  3. AS metadata: advertise client_id_metadata_document_supported: true.
  4. SSRF guards on the fetch (the URL arrives from an anonymous party): https only, block private/link-local/loopback IPs (incl. DNS-rebinding re-check), response size limit, timeout, content-type check, positive+negative cache.
  5. Tests mirroring the DCR suite: happy path, redirect_uri mismatch vs the doc, SSRF-guard rejections, cache behavior.

When

Deliberately deferred: stock Claude clients connect fine via DCR today. Trigger for picking this up — authorize errors in the logs with URL-shaped client_id values (clients starting to send CIMD identifiers).

Refs: MCP auth spec 2025-11-25 (SEP-991), draft-ietf-oauth-client-id-metadata-document.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions