Skip to content

symfonic.platform.transport_records

transport_records

Point-memory routes; scoped reads and authenticated audited deletion.

verified_principal async

verified_principal(resolver, tenant, authorization)

Preserve authenticated identity for audit, not just its derived scope.

Source code in src/symfonic/platform/transport_records.py
async def verified_principal(resolver, tenant, authorization):
    """Preserve authenticated identity for audit, not just its derived scope."""
    from fastapi import HTTPException

    from symfonic.platform.errors import AuthenticationError, AuthorizationError
    from symfonic.platform.values import RequestCredentials

    headers = {"x-tenant-id": tenant}
    if authorization:
        headers["authorization"] = authorization
    try:
        value = resolver.resolve(RequestCredentials(headers=headers))
        return await value if inspect.isawaitable(value) else value
    except AuthenticationError as denied:
        raise HTTPException(401, str(denied)) from denied
    except AuthorizationError as denied:
        raise HTTPException(403, str(denied)) from denied