Skip to content

refactor(mcp): use library CIMD support, drop custom resolver - #655

Merged
pcfreak30 merged 1 commit into
developfrom
refactor/mcp-oauth-cimd
Sep 1, 2026
Merged

refactor(mcp): use library CIMD support, drop custom resolver#655
pcfreak30 merged 1 commit into
developfrom
refactor/mcp-oauth-cimd

Conversation

@pcfreak30

@pcfreak30 pcfreak30 commented Sep 1, 2026

Copy link
Copy Markdown
Member

Upgrades go.lumeweb.com/oauth to v0.1.5 and switches the MCP OAuth server to
the library's RFC 9291 CIMD resolution via AuthorizationServer.WithCIMDResolver.

Removes the pinner-cli-specific CIMD implementation (metadata cache, host
allowlist, and client deactivation) in favor of the library's always-on SSRF
gate. client_id_metadata_document_supported is advertised only when a
resolver is attached, and the now-obsolete CIMD unit tests are removed.


Summary

This pull request refactors the MCP OAuth server to delegate Client-Initiated Backchannel Authentication (CIMD) client metadata resolution to the underlying OAuth library rather than using a custom in-house implementation.

Changes

CIMD Resolution Delegated to Library

  • Removed the custom CIMD client metadata resolver, including its caching mechanism, host allowlist, SSRF protections, and client registration logic
  • The OAuth server now uses the library's built-in WithCIMDResolver support, which provides RFC 9291 CIMD resolution with its own TTL-based caching and always-on SSRF gate
  • The server now advertises client_id_metadata_document_supported only when CIMD is actually enabled

Simplified Server Structure

  • Removed extensive custom code for:
    • CIMD metadata document fetching and validation
    • Host allowlisting and SSRF defense
    • Client registration/deactivation logic
    • TTL-based cache management
  • The server now relies entirely on the library for CIMD resolution, reducing maintenance burden and ensuring consistent behavior with the shared OAuth implementation

Cleanup

  • Removed the now-unused cache, host allowlist, and client registration helper functions
  • Removed corresponding tests for the replaced custom implementation
  • The periodic reaper now only handles eviction of expired durable rows via the authorization server

Impact

This refactor reduces code duplication and potential inconsistencies by leveraging the library's mature CIMD support. The CIMD resolution is now open-by-default (any public HTTPS URL passing the library's SSRF gate is accepted), rather than being restricted to a small hardcoded allowlist of known client hosts, which improves flexibility for legitimate clients while maintaining security through the library's built-in protections.

Upgrade go.lumeweb.com/oauth to v0.1.5, which ships RFC 9291 client
identifier metadata document (CIMD) resolution via AuthorizationServer.
WithCIMDResolver. Attach a CIMDResolver in NewOAuthServer and delete the
pinner-cli-specific CIMD implementation (cache, host allowlist, SSRF,
ensureClient/deactivateClient, reaper eviction), now handled by the
library's always-on SSRF gate. AS metadata advertises
client_id_metadata_document_supported only when a resolver is attached.
Remove the CIMD unit tests that covered the deleted custom logic.
@kody-ai

kody-ai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

Comment thread internal/mcp/auth/oauth.go
Comment thread internal/mcp/auth/oauth.go

@kody-ai kody-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcfreak30
pcfreak30 merged commit 6544347 into develop Sep 1, 2026
12 of 13 checks passed
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Code Coverage Report

Total Coverage: 50.0%

Generated from commit: 01938e5
Repository: LumeWeb/pinner-cli

@pcfreak30
pcfreak30 deleted the refactor/mcp-oauth-cimd branch September 1, 2026 03:50
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