File size: 447 Bytes
d2d1903 | 1 2 3 4 5 6 7 8 9 10 11 | from fastapi import HTTPException
from error_catalog import error
def ensure_tenant(principal, tenant_id):
if principal.get("tenant_id") != tenant_id:
raise HTTPException(status_code=403, detail=error("ORG-AUTH-003", tenant_id, "Use an API key for this tenant."))
return True
def api_error(code, status_code=400, detail="", suggestion=""):
raise HTTPException(status_code=status_code, detail=error(code, detail, suggestion))
|