mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-28 06:23:07 +00:00
fix: use HMAC for caller cache namespaces
This commit is contained in:
parent
b59d30aaba
commit
0b13b2eaca
1 changed files with 5 additions and 1 deletions
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
import ast
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
|
|
@ -643,7 +644,10 @@ class Cache:
|
|||
"user_role": getattr(auth_object, "user_role", None),
|
||||
}
|
||||
identity = json.dumps(identity_fields, sort_keys=True, default=str, separators=(",", ":"))
|
||||
authenticated_namespace = "caller:" + hashlib.sha256(identity.encode("utf-8")).hexdigest()[:32]
|
||||
caller_digest = hmac.new(
|
||||
b"litellm-cache-namespace-v1", identity.encode("utf-8"), hashlib.sha256
|
||||
).hexdigest()
|
||||
authenticated_namespace = "caller:" + caller_digest[:32]
|
||||
break
|
||||
requested_namespace_value: Final = dynamic_cache_control.get("namespace")
|
||||
requested_namespace: Final[str | None] = (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue