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))