Add OAuth 2.1 authentication support with external provider integration#73
Open
r33drichards wants to merge 3 commits into
Open
Add OAuth 2.1 authentication support with external provider integration#73r33drichards wants to merge 3 commits into
r33drichards wants to merge 3 commits into
Conversation
MCP-V8 Load Test Benchmark ReportComparison of single-node vs 3-node cluster at various request rates. Results
P95 Latency
Notes
|
Enable optional OAuth authentication for HTTP and SSE transports via --oauth flag. When enabled, MCP and API endpoints require a valid Bearer token while OAuth endpoints remain public for client discovery, registration, and token exchange. Features: - RFC 7591 dynamic client registration (/oauth/register) - Authorization code flow with PKCE S256 support (/oauth/authorize) - Token exchange endpoint (/oauth/token) - OAuth metadata discovery (/.well-known/oauth-authorization-server) - Bearer token validation middleware for protected routes - Configurable issuer URL via --oauth-issuer for reverse proxy setups https://claude.ai/code/session_01EzekKCTDGrff31LeVZZpyu
Add external OIDC provider support to the OAuth module so the MCP server
can delegate authentication to Keycloak. Token validation uses Keycloak's
introspection endpoint (RFC 7662).
New CLI flags:
--oauth-provider-url External OIDC provider URL (Keycloak realm)
--oauth-client-id Server's client ID for introspection
--oauth-client-secret Server's client secret for introspection
New files:
- docker-compose.oauth.yml: Full stack with Keycloak + MCP-JS
- keycloak/realm.json: Pre-configured realm with mcp-client (public),
mcp-server (confidential), and testuser/testpassword
- OAUTH_TESTING.md: Step-by-step guide for testing with curl and
Claude Code
https://claude.ai/code/session_01EzekKCTDGrff31LeVZZpyu
535483c to
a9d54cd
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive OAuth 2.1 authentication support to the MCP server, enabling secure token-based access control for HTTP/SSE transports. The implementation supports both a built-in OAuth provider and delegation to external OIDC providers (e.g., Keycloak).
Key Changes
New OAuth module (
server/src/oauth.rs): Complete OAuth 2.1 implementation including:.well-known/oauth-authorization-server)Dual-mode operation:
CLI options for OAuth configuration:
--oauth: Enable OAuth authentication--oauth-issuer: Set the issuer URL (defaults to server's base URL)--oauth-provider-url: External OIDC provider URL--oauth-client-id/--oauth-client-secret: Credentials for provider introspectionTransport integration: Updated HTTP and SSE transport initialization to apply token validation middleware when OAuth is enabled
Testing infrastructure:
docker-compose.oauth.yml: Pre-configured stack with Keycloak as external providerkeycloak/realm.json: Pre-configured realm with test users and clientsOAUTH_TESTING.md: Comprehensive testing guide with curl examples and troubleshootingImplementation Details
https://claude.ai/code/session_01EzekKCTDGrff31LeVZZpyu