Skip to main content

Overview

Auth providers validate credentials and manage user sessions. The gateway supports multiple authentication methods including API keys, OAuth 2.0, JWT, and custom schemes.

AuthProvider Interface

All authentication providers must implement the AuthProvider abstract base class from src/secure_mcp_gateway/plugins/auth/base.py.

Required Methods

Optional Methods

Data Models

AuthCredentials

Container for various credential types:
Sensitive fields are automatically masked in string representations using __repr__().

AuthResult

Authentication result with user information:

AuthStatus Enum

AuthMethod Enum

Example: API Key Provider

Here’s a complete implementation from src/secure_mcp_gateway/plugins/auth/example_providers.py:376:

Example: OAuth2 Provider

From src/secure_mcp_gateway/plugins/auth/example_providers.py:31:

Example: JWT Provider

From src/secure_mcp_gateway/plugins/auth/example_providers.py:230:

Configuration

Register your auth provider in the config file:

Helper Utilities

Credential Extraction

The gateway automatically extracts credentials from request context:

Sensitive Data Masking

Testing Your Provider

Plugin Overview

Learn about the plugin system architecture

Configuration

Configure authentication settings