AuthHandler
AuthHandler provides a unified authentication layer supporting HTTP Basic Auth,
Bearer tokens, and API keys. It integrates with both FastAPI (as a dependency) and
Flask (as a decorator), and is used internally by the
mcp-gateway and agent
webhook endpoints.
Properties
security_config
A SecurityConfig
instance that provides the authentication credentials. The handler reads:
- Basic auth username/password from
get_basic_auth() - Bearer token from the
bearer_tokenattribute (if set) - API key and header name from the
api_keyandapi_key_headerattributes (if set)
Methods
flask_decorator
Flask decorator for protecting routes with authentication.
get_auth_info
Get a summary of configured authentication methods.
get_fastapi_dependency
Get a FastAPI dependency function for protecting routes.
verify_api_key
Verify an API key using constant-time comparison.
verify_basic_auth
Verify HTTP Basic Auth credentials using constant-time comparison.
verify_bearer_token
Verify a Bearer token using constant-time comparison.