mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(proxy): treat custom_auth as alternative auth for the missing master key warning
This commit is contained in:
parent
741614b70a
commit
42e221fe90
2 changed files with 14 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue