mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
fix(proxy): require opt in for audit header fallback
This commit is contained in:
parent
09c4d0d01e
commit
f48dfdbdd9
2 changed files with 18 additions and 2 deletions
|
|
@ -42,7 +42,7 @@ def get_audit_log_changed_by(
|
|||
) -> Optional[str]:
|
||||
if litellm_changed_by and _allows_litellm_changed_by_header(user_api_key_dict):
|
||||
return litellm_changed_by
|
||||
return user_api_key_dict.user_id or litellm_changed_by or litellm_proxy_admin_name
|
||||
return user_api_key_dict.user_id or litellm_proxy_admin_name
|
||||
|
||||
|
||||
def _resolve_audit_log_callback(name: str) -> Optional[CustomLogger]:
|
||||
|
|
|
|||
|
|
@ -107,9 +107,25 @@ def test_get_audit_log_changed_by_honors_header_with_team_opt_in():
|
|||
)
|
||||
|
||||
|
||||
def test_get_audit_log_changed_by_falls_back_to_header_when_user_id_missing():
|
||||
def test_get_audit_log_changed_by_ignores_header_without_opt_in_when_user_id_missing():
|
||||
user_api_key_dict = UserAPIKeyAuth(api_key="test-key")
|
||||
|
||||
assert (
|
||||
get_audit_log_changed_by(
|
||||
litellm_changed_by="spoofed-user",
|
||||
user_api_key_dict=user_api_key_dict,
|
||||
litellm_proxy_admin_name="proxy-admin",
|
||||
)
|
||||
== "proxy-admin"
|
||||
)
|
||||
|
||||
|
||||
def test_get_audit_log_changed_by_honors_header_with_opt_in_when_user_id_missing():
|
||||
user_api_key_dict = UserAPIKeyAuth(
|
||||
api_key="test-key",
|
||||
metadata={"allow_litellm_changed_by_header": True},
|
||||
)
|
||||
|
||||
assert (
|
||||
get_audit_log_changed_by(
|
||||
litellm_changed_by="delegated-user",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue