(proxy) - Auth fix, ensure re-using safe request body for checking model field (#7222)

* litellm fix auth check

* fix _read_request_body

* test_auth_with_form_data_and_model

* fix auth check

* fix _read_request_body

* fix _safe_get_request_headers
This commit is contained in:
Ishaan Jaff 2024-12-14 12:01:25 -08:00 committed by GitHub
parent ec36353b41
commit 9432812c90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 87 additions and 16 deletions

View file

@ -899,12 +899,10 @@ async def user_api_key_auth( # noqa: PLR0915
# the validation will occur when checking the team has access to this model
pass
else:
try:
data = await request.json()
except json.JSONDecodeError:
data = {} # Provide a default value, such as an empty dictionary
model = data.get("model", None)
fallback_models: Optional[List[str]] = data.get("fallbacks", None)
model = request_data.get("model", None)
fallback_models: Optional[List[str]] = request_data.get(
"fallbacks", None
)
if model is not None:
await can_key_call_model(