Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix JWT auth email domain validation error message

Julio Quinteros Pro3f4ba9f03f62
diff --git a/litellm/proxy/auth/handle_jwt.py b/litellm/proxy/auth/handle_jwt.py
index 15056cf64e6..f5c39230285 100644
--- a/litellm/proxy/auth/handle_jwt.py
+++ b/litellm/proxy/auth/handle_jwt.py
@@ -1066,6 +1066,15 @@ class JWTAuthManager:
f"JWT Auth: Resolved org_alias='{org_alias}' to org_id='{org_object.organization_id}'"
)
+ # Check if email domain is allowed before attempting to get/create user
+ if valid_user_email is False:
+ raise ProxyException(
+ message=f"Email domain not allowed. User email: {user_email}. Allowed domain: {jwt_handler.litellm_jwtauth.user_allowed_email_domain}",
+ type=ProxyErrorTypes.auth_error,
+ param="user_email",
+ code=403,
+ )
+
user_object: Optional[LiteLLM_UserTable] = None
if user_id:
user_object = (