mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix(auth): guard JWTHandler.is_jwt() against None token
When JWT auth is enabled and a request arrives without an Authorization header (e.g. health checks, monitoring), api_key is None due to APIKeyHeader(auto_error=False). The is_jwt() call crashes with AttributeError: 'NoneType' object has no attribute 'split'. Return False for None tokens since they are not JWTs.
This commit is contained in:
parent
8f425ec3ff
commit
e36ab04a18
1 changed files with 3 additions and 1 deletions
|
|
@ -89,7 +89,9 @@ class JWTHandler:
|
|||
self.leeway = leeway
|
||||
|
||||
@staticmethod
|
||||
def is_jwt(token: str):
|
||||
def is_jwt(token: Optional[str]):
|
||||
if token is None:
|
||||
return False
|
||||
parts = token.split(".")
|
||||
return len(parts) == 3
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue