fix(proxy): treat custom_auth as alternative auth for the missing master key warning

This commit is contained in:
Devin AI 2026-09-11 23:43:50 +00:00
parent 741614b70a
commit 42e221fe90
2 changed files with 14 additions and 2 deletions

View file

@ -7,7 +7,7 @@ INSECURE_MASTER_KEYS: Final = frozenset({"sk-1234"})
InsecureMasterKeyReason = Literal["example_key", "missing"]
_ALTERNATIVE_AUTH_SETTINGS: Final = ("enable_jwt_auth", "enable_oauth2_auth", "enable_oauth2_proxy_auth")
_ALTERNATIVE_AUTH_SETTINGS: Final = ("enable_jwt_auth", "enable_oauth2_auth", "enable_oauth2_proxy_auth", "custom_auth")
def alternative_auth_enabled(general_settings: Mapping[str, object]) -> bool:

View file

@ -1,5 +1,11 @@
from typing import Final
from litellm.litellm_core_utils.secret_redaction import redact_string
from litellm.proxy.auth.master_key_policy import insecure_master_key_reason, insecure_master_key_warning
from litellm.proxy.auth.master_key_policy import (
alternative_auth_enabled,
insecure_master_key_reason,
insecure_master_key_warning,
)
def test_insecure_master_key_reason_for_example_key():
@ -19,6 +25,12 @@ def test_insecure_master_key_reason_none_with_alternative_auth():
assert insecure_master_key_reason(None, alternative_auth_enabled=True) is None
def test_insecure_master_key_reason_none_with_custom_auth():
general_settings: Final = {"custom_auth": "my_package.custom_auth_handler"}
assert insecure_master_key_reason(None, alternative_auth_enabled=alternative_auth_enabled(general_settings)) is None
def test_insecure_master_key_warning_returned_for_example_key():
warning = insecure_master_key_warning("sk-1234", alternative_auth_enabled=False)