Provides FastAPI authentication dependency for HTTP and WebSocket.
# Source: https://github.com/Upsonic/Upsonic | License: MIT | Copyright 2024 Upsonic Teknoloji A.Ş
# Provided via justclaw.it.com; keep this notice with the code.
"""
Authentication module for Interface Manager.
This module provides authentication functionality for both HTTP requests (Bearer token)
and WebSocket connections. Authentication can be disabled by not setting a security key.
"""
from typing import Optional
from fastapi import Depends, HTTPException, status
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from upsonic.interfaces.settings import InterfaceSettings
# Global HTTPBearer instance for dependency injection
security = HTTPBearer(auto_error=False)
def get_authentication_dependency(settings: InterfaceSettings):
"""
Create an authenticatio
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key