qfa.api.dependencies#
FastAPI dependency functions for authentication and service injection.
Functions
|
Validate a Bearer token from the Authorization header. |
|
Return the orchestrator from app state. |
|
Return the usage repository from app state, or raise 503 if disabled. |
|
FastAPI dependency that authenticates and checks superuser status. |
- qfa.api.dependencies.get_orchestrator(request: Request) Orchestrator[source]#
Return the orchestrator from app state.
- Parameters:
request (Request) – The incoming HTTP request.
- Returns:
The orchestrator service instance.
- Return type:
- qfa.api.dependencies.get_usage_repo(request: Request) UsageRepositoryPort[source]#
Return the usage repository from app state, or raise 503 if disabled.
- Parameters:
request (Request) – The incoming HTTP request.
- Returns:
The usage repository instance.
- Return type:
- Raises:
HTTPException – 503 if usage tracking is not enabled.
- async qfa.api.dependencies.authenticate_request(request: Request, credentials: HTTPAuthorizationCredentials = Security(dependency=<fastapi.security.http.HTTPBearer object>, use_cache=True, scope=None, scopes=None)) TenantApiKey[source]#
Validate a Bearer token from the Authorization header.
- Parameters:
request (Request) – The incoming HTTP request.
credentials (HTTPAuthorizationCredentials) – The parsed Authorization header credentials.
- Returns:
The authenticated tenant API key.
- Return type:
- Raises:
AuthenticationError – If the credentials are missing or invalid.
- qfa.api.dependencies.require_superuser(tenant: TenantApiKey = Depends(dependency=<function authenticate_request>, use_cache=True, scope=None)) TenantApiKey[source]#
FastAPI dependency that authenticates and checks superuser status.
- Parameters:
tenant (TenantApiKey) – The authenticated tenant (injected by
authenticate_request).- Returns:
The authenticated superuser tenant.
- Return type:
- Raises:
AuthorizationError – If the tenant is not a superuser.