INNER CODE UNIT · Python
_a2a_agent_auth
evalstate/fast-agent · src/fast_agent/a2a/server.py:153
def _a2a_agent_auth(context: RequestContext) -> AgentAuth | None:
token = _bearer_token_from_call_context(context)
return AgentAuth.bearer(token) if token is not None else None
class A2ABearerAuthMiddleware:
"""Require bearer authentication for A2A action routes."""
def __init__(self, app: ASGIApp, *, provider: str) -> None:
self.app = app
self.provider = provider
self.token_verifier = HuggingFaceOAuthOrHubTokenVerifier()
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
if scope["type"] != "http":
await self.app(scope, receive, send)
return