For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • BedrockAgent
      • CLI Tools
      • Configuration
        • AuthHandler
          • flask_decorator
          • get_auth_info
          • get_fastapi_dependency
          • verify_api_key
          • verify_basic_auth
          • verify_bearer_token
        • ConfigLoader
        • Environment Variables
        • SecurityConfig
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions
      • LiveWire
      • MCP Gateway
      • PomBuilder
      • Prefabs
      • Search
      • SkillBase
      • Skills
      • SWAIGFunction
      • SWMLBuilder
      • SWMLService
      • WebService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • Chat
      • Compat
      • Datasphere
      • Fabric
      • Imported Numbers
      • Logs
      • Lookup
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSub
      • Queues
      • Recordings
      • Registry
      • RestClient
      • Short Codes
      • SignalWireRestError
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Properties
  • Methods
  • Example
AgentsConfiguration

AuthHandler

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

flask_decorator

Next
Built with

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.

1from signalwire.core.auth_handler import AuthHandler
2from signalwire.core.security_config import SecurityConfig
3
4security = SecurityConfig()
5auth = 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

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.

Example

1from signalwire.core.security_config import SecurityConfig
2from signalwire.core.auth_handler import AuthHandler
3
4security = SecurityConfig()
5auth = AuthHandler(security)
6
7# Check which methods are configured
8info = auth.get_auth_info()
9print(info)
10# {'basic': {'enabled': True, 'username': 'signalwire'}}