AuthHandler

View as MarkdownOpen in Claude

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.

from signalwire.core.auth_handler import AuthHandler
from signalwire.core.security_config import SecurityConfig
security = SecurityConfig()
auth = AuthHandler(security)

Properties

security_config
SecurityConfigRequired

A SecurityConfig instance that provides the authentication credentials. The handler reads:

  • Basic auth username/password from get_basic_auth()
  • Bearer token from the bearer_token attribute (if set)
  • API key and header name from the api_key and api_key_header attributes (if set)

Methods

Example

from signalwire.core.security_config import SecurityConfig
from signalwire.core.auth_handler import AuthHandler
security = SecurityConfig()
auth = AuthHandler(security)
# Check which methods are configured
info = auth.get_auth_info()
print(info)
# {'basic': {'enabled': True, 'username': 'signalwire'}}