qfa.services.auth_orchestrator#
Application service for authentication and management operations.
Classes
|
Coordinate key and tenant lookup and management across configured ports. |
- class qfa.services.auth_orchestrator.AuthOrchestrator(auth_lookup_ports: list[AuthLookupPort], auth_management_port: AuthManagementPort)[source]#
Bases:
objectCoordinate key and tenant lookup and management across configured ports.
Initialize a AuthOrchestrator manager with lookup and management ports.
- Parameters:
auth_lookup_ports (list[AuthLookupPort]) – One or more authentication lookup ports used to validate keys and list keys.
auth_management_port (AuthManagementPort) – The auth-management port used for mutations.
- async validate_api_key(api_key: str) TenantApiKey[source]#
Validate an API key against available authentication backends.
- Parameters:
api_key (str) – API key supplied by the caller.
- Returns:
The matching tenant API key record.
- Return type:
- Raises:
AuthenticationError – If no configured authentication backend recognizes the key.
- async add_tenant(tenant_name: str, allows_superusers: bool = False) str[source]#
Add a new tenant through the configured auth-management backend.
- async delete_tenant(tenant_id: str) None[source]#
Delete an existing tenant through the configured auth-management backend.
- Parameters:
tenant_id (str) – The unique identifier of the tenant to delete.
- async add_key(key_name: str, tenant_id: str, is_superuser: bool = False) KeyCreationResponse[source]#
Add a key through the configured auth-management backend.
- Parameters:
- Returns:
The created key identifier and plaintext API key as
(key_id, api_key).- Return type:
- async delete_key(key_id: str) None[source]#
Delete a key through the configured auth-management backend.
- Parameters:
key_id (str) – Unique identifier of the tenant API key record to remove.
- async get_tenants() list[TenantInfo][source]#
Get all tenants through the configured auth-management backend.
- Returns:
List of tenant metadata objects (tenant_id, name, allows_superusers).
- Return type:
- async get_auth_keys(tenant_id: str | None = None) list[AuthKeyInfo][source]#
Get all API keys through the configured auth-management backend.
Can be filtered by tenant_id if provided.
- Parameters:
tenant_id (str) – Unique identifier of the tenant to list keys for.
- Returns:
List of API key informations associated with the tenant.
- Return type: