refactor(types): move is_jwt into litellm.types.proxy.auth.user_api_key_auth (#45747)

* refactor(types): move LitellmUserRoles and KeyManagementRoutes into litellm.types.proxy.auth.user_roles

Part of LIT-9423

* refactor(types): move is_jwt into litellm.types.proxy.auth.user_api_key_auth

Part of LIT-9423

* refactor(auth): alias is_jwt import so JWTHandler.is_jwt is not read as recursive
This commit is contained in:
nate-berri 2026-10-10 12:08:56 -07:00 • committed by GitHub
parent a859d844ed
commit 7831d8a991
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 7 deletions

View file

@ -67,6 +67,7 @@ from litellm.types.proxy.agent_identity import ManagedAgentContext
from litellm.types.proxy.auth.special_headers import (
SpecialHeaders as SpecialHeaders, # noqa: PLC0414 # public re-export
)
from litellm.types.proxy.auth.user_api_key_auth import is_jwt
from litellm.types.proxy.carried_budget_state import (
OrgBudgetSnapshot,
TeamBudgetSnapshot,
@ -3482,9 +3483,7 @@ class UserAPIKeyAuth(LiteLLM_VerificationTokenView): # the expected response ob
normalized = normalized[7:]
if normalized.startswith("sk-"):
return hash_token(normalized)
from litellm.proxy.auth.handle_jwt import JWTHandler
if JWTHandler.is_jwt(token=normalized):
if is_jwt(token=normalized):
return f"hashed-jwt-{hash_token(token=normalized)}"
return normalized

View file

@ -75,6 +75,7 @@ from litellm.repositories.user_repository import UserRepository
from litellm.types.agents import AgentResponse
from litellm.types.proxy.agent_identity import AgentIdentityFailure
from litellm.types.proxy.auth.auth_checks import UserNotFoundError
from litellm.types.proxy.auth.user_api_key_auth import is_jwt as is_jwt_token
from .auth_checks import (
TeamNotFoundError,
@ -276,10 +277,7 @@ class JWTHandler:
@staticmethod
def is_jwt(token: str | None) -> bool:
if token is None:
return False
parts: Final = token.split(".")
return len(parts) == 3
return is_jwt_token(token=token)
@staticmethod
def get_unverified_claims(token: str) -> dict | None:

View file

@ -0,0 +1,8 @@
from typing import Final
def is_jwt(token: str | None) -> bool:
if token is None:
return False
parts: Final = token.split(".")
return len(parts) == 3