Skip to content

Add OAuth 2.1 support for MCP server - #448

Closed
kaospr wants to merge 1 commit into
mainfrom
feature/oauth
Closed

Add OAuth 2.1 support for MCP server#448
kaospr wants to merge 1 commit into
mainfrom
feature/oauth

Conversation

@kaospr

@kaospr kaospr commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds OAuth 2.1 authorization for MCP endpoints using Doorkeeper with PKCE (S256 only), authorization code flow, and hashed token storage
  • Implements RFC 7591 dynamic client registration at /oauth/register with IP-based rate limiting, redirect URI allowlisting (localhost + claude.ai), and input validation
  • Adds Rack middleware (McpOauthMiddleware) that authenticates MCP requests via Bearer tokens and passes signed user identity to MCP tools using MessageVerifier
  • Includes .well-known/oauth-protected-resource and .well-known/oauth-authorization-server metadata endpoints
  • Scheduled cleanup jobs for expired tokens (30+ days) and stale unused registrations (24h)
  • Rack::Attack rate limiting on the registration endpoint

Test plan

  • Dynamic registration controller tests (valid params, defaults, validation, IP rate limit, redirect URI restrictions)
  • Full PKCE authorization code flow integration test
  • Token validation tests (expired, revoked, wrong scope, forged headers)
  • Metadata endpoint tests
  • Cleanup job tests (expired tokens, stale applications, retention of active records)
  • Manual test: register client, complete OAuth flow, use MCP tools with token
  • Verify Rack::Attack rate limiting in development

🤖 Generated with Claude Code

@Jordybastien

Copy link
Copy Markdown
Collaborator

⚠️ This PR was closed by an attacker using a stolen access token of mine, not by me (part of a wider supply-chain attack, GitHub discussion #188732). Do not build/run the tampered branch, it hides a credential-stealing payload in postcss.config.js. Recovery is simple: push your local copy of the branch again (git push --force-with-lease) and the malicious commit is gone. The stolen token is revoked, and my credentials rotated — apologies for the disruption.

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.

2 participants