FastAPI dependencies for bearer token authentication and principal extraction.
# Source: https://github.com/Negai-ai/AgentClaw | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""FastAPI authentication dependencies for public-facing API routes."""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Optional
from fastapi import HTTPException, Request
from fastapi.responses import JSONResponse
from agentclaw.api.auth.token import AdminTokenManager, WorkflowAPIKeyManager
from agentclaw.utils.security import safe_compare_digest
@dataclass(frozen=True)
class AuthPrincipal:
"""Authenticated caller identity.
user_id and tenant_id are intentionally reserved for a future multi-user
edition. The current perso
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key