From 42e221fe9006f8d6621a60d315449c223cd8600a Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 11 Sep 2026 23:43:50 +0000 Subject: [PATCH] fix(proxy): treat custom_auth as alternative auth for the missing master key warning --- litellm/proxy/auth/master_key_policy.py | 2 +- .../proxy/auth/test_master_key_policy.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/auth/master_key_policy.py b/litellm/proxy/auth/master_key_policy.py index 23f39f1cf03..3b34be0bb07 100644 --- a/litellm/proxy/auth/master_key_policy.py +++ b/litellm/proxy/auth/master_key_policy.py @@ -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: diff --git a/tests/test_litellm/proxy/auth/test_master_key_policy.py b/tests/test_litellm/proxy/auth/test_master_key_policy.py index 3f069e380c4..1b7d5a086f8 100644 --- a/tests/test_litellm/proxy/auth/test_master_key_policy.py +++ b/tests/test_litellm/proxy/auth/test_master_key_policy.py @@ -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)