Merge pull request #21212 from BerriAI/fix/jwt-email-domain-validation-error

Fix: JWT email domain validation error message
This commit is contained in:
jquinter 2026-02-14 16:20:08 -03:00 committed by GitHub
commit a15a2fa77c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -3776,7 +3776,7 @@ class LiteLLM_JWTAuth(LiteLLMPydanticObjectBase):
def __init__(self, **kwargs: Any) -> None:
# get the attribute names for this Pydantic model
allowed_keys = self.__annotations__.keys()
allowed_keys = LiteLLM_JWTAuth.__annotations__.keys()
invalid_keys = set(kwargs.keys()) - allowed_keys
user_roles_jwt_field = kwargs.get("user_roles_jwt_field")

View file

@ -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 = (