mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix(auth): drop env-credential hint from 401 when env login is disabled
This commit is contained in:
parent
8576cf74c2
commit
78893723f7
2 changed files with 9 additions and 1 deletions
|
|
@ -362,8 +362,13 @@ async def authenticate_user(
|
|||
code=401,
|
||||
)
|
||||
else:
|
||||
env_credentials_hint: Final = (
|
||||
"\nCheck 'UI_USERNAME', 'UI_PASSWORD' in .env file"
|
||||
if is_env_credential_login_enabled(general_settings)
|
||||
else ""
|
||||
)
|
||||
raise ProxyException(
|
||||
message="Invalid credentials used to access UI.\nCheck 'UI_USERNAME', 'UI_PASSWORD' in .env file",
|
||||
message=f"Invalid credentials used to access UI.{env_credentials_hint}",
|
||||
type=ProxyErrorTypes.auth_error,
|
||||
param="invalid_credentials",
|
||||
code=401,
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ async def test_authenticate_user_invalid_credentials():
|
|||
assert exc_info.value.type == ProxyErrorTypes.auth_error
|
||||
assert exc_info.value.code == "401"
|
||||
assert "Invalid credentials" in exc_info.value.message
|
||||
assert "UI_USERNAME" in exc_info.value.message
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -829,6 +830,8 @@ class TestDisableEnvCredentialLogin:
|
|||
|
||||
assert exc_info.value.type == ProxyErrorTypes.auth_error
|
||||
assert exc_info.value.code == "401"
|
||||
assert "UI_USERNAME" not in exc_info.value.message
|
||||
assert "UI_PASSWORD" not in exc_info.value.message
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_rejects_master_key_fallback_when_disabled(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue