Skip to content

Feature/oauth 2.1 support #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

westonbrown
Copy link
Collaborator

OAuth 2.1 Authentication Integration for MCP Gateway

  • Adds comprehensive OAuth 2.1 authentication with support for AWS Cognito, Okta, and generic OAuth providers
  • Implements fine-grained scope-based authorization with server-level and tool-level access control
  • Maintains full compatibility with both SSE and StreamableHTTP transport protocols
  • Provides secure session management with JWT validation and PKCE support

Features

🔐 Multi-Provider OAuth 2.1 Support

  • AWS Cognito: Full implementation with group-based permissions
  • Okta: Complete integration with tenant-based authentication
  • Generic OAuth: Configurable for any OAuth 2.1 compliant provider
  • PKCE Security: Authorization code flow with Proof Key for Code Exchange

🎯 Granular Access Control

  • Registry permissions: mcp:registry:admin, mcp:registry:read
  • Server permissions: mcp:server:{name}:execute, mcp:server:{name}:toggle
  • Tool permissions: mcp:server:{name}:tool:{tool}:execute
  • Automatic group-to-scope mapping from identity provider groups

🚀 Full Protocol Compatibility

  • SSE Transport: /api/execute/{service} endpoints with streaming support
  • StreamableHTTP: /api/streamable/{service} endpoints for bidirectional communication
  • Dynamic Nginx configuration for proxy routing
  • Service credential pass-through via HTTP headers and direct parameters

🛡️ Enterprise Security

  • JWT signature verification with JWKS endpoint validation
  • Session invalidation tracking prevents token reuse after logout
  • Strong SECRET_KEY validation with cryptographic requirements

Technical Implementation

  • Secure session fingerprinting using unique session IDs prevents logout conflicts
  • Middleware-based authentication with request-level user context
  • OAuth state management with CSRF protection and cache-busting parameters
  • Provider abstraction allowing easy addition of new identity providers

Test Plan

  • ✅ OAuth login flow with Cognito integration
  • ✅ Scope-based authorization enforcement
  • ✅ Session management and logout functionality
  • ✅ Multi-transport protocol support (SSE + StreamableHTTP)
  • ✅ Server toggle permissions and tool execution
  • ✅ JWT validation and signature verification

This commit implements OAuth 2.1 authentication with support for multiple identity providers, scope-based access control, and both SSE and StreamableHTTP transport protocols. Key changes include:

- Complete OAuth 2.1 implementation with authorization code flow and PKCE
- Support for AWS Cognito, Okta, and generic OAuth providers
- Fine-grained scope-based access control for server and tool access
- Support for both SSE (/api/execute/) and StreamableHTTP (/api/streamable/) transports
- Comprehensive documentation in README.md and new oauth.md guide

Tests show 100% success rate with both admin and limited users, confirming:
- Proper authentication and authorization flows
- Correct scope-based access restrictions
- Working transport protocols for SSE and StreamableHTTP
This commit adds the necessary infrastructure for OAuth 2.1 support:

- Docker configuration with OAuth environment variables
- Updated entrypoint script with OAuth integration
- Nginx configuration for OAuth endpoints
- Updated dependencies in pyproject.toml
- UI templates with OAuth login flow integration
- Updated startup script
@westonbrown westonbrown added the enhancement New feature or request label May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants