mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
Merge pull request #21212 from BerriAI/fix/jwt-email-domain-validation-error
Fix: JWT email domain validation error message
This commit is contained in:
commit
a15a2fa77c
2 changed files with 10 additions and 1 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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 = (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue