mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
fix(auth_v2): resolve mypy arg-type errors in security and jwt credential mapping
This commit is contained in:
parent
6e51b3fc90
commit
ffbcb8b48c
2 changed files with 9 additions and 3 deletions
|
|
@ -64,6 +64,7 @@ def credential_from_claims(
|
|||
) -> Credential:
|
||||
header = jwt.get_unverified_header(token)
|
||||
issuer = claims.get("iss")
|
||||
jti = claims.get("jti")
|
||||
return Credential(
|
||||
scheme=scheme,
|
||||
method=method,
|
||||
|
|
@ -73,7 +74,7 @@ def credential_from_claims(
|
|||
scopes=split_scope(claims.get("scope")),
|
||||
claims=claims,
|
||||
credential_ref=CredentialRef(
|
||||
key_id=header.get("kid"), token_id=claims.get("jti")
|
||||
key_id=header.get("kid"), token_id=jti if isinstance(jti, str) else None
|
||||
),
|
||||
subject_token=token,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
import os
|
||||
from typing import Annotated, Callable, Dict, List, Optional
|
||||
from typing import TYPE_CHECKING, Annotated, Callable, Dict, List, Optional, cast
|
||||
|
||||
from fastapi import Request, Security
|
||||
from fastapi.security import SecurityScopes
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from redis.asyncio import Redis
|
||||
|
||||
from litellm._redis import get_redis_async_client
|
||||
from litellm.proxy.auth_v2 import errors
|
||||
from litellm.proxy.auth_v2.authenticators import (
|
||||
|
|
@ -50,7 +53,9 @@ def _open_session_store(
|
|||
silently stranding state on one pod.
|
||||
"""
|
||||
if any(os.getenv(signal) for signal in _REDIS_ENV_SIGNALS):
|
||||
return RedisSessionStore(get_redis_async_client(), namespace, default_ttl)
|
||||
return RedisSessionStore(
|
||||
cast("Redis", get_redis_async_client()), namespace, default_ttl
|
||||
)
|
||||
return InMemorySessionStore(namespace, default_ttl)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue