fix(proxy): hide LDAP credentials in validation errors
Some checks failed
Cost map pins recheck / rerun-cost-map-guard (push) Has been cancelled
LiteLLM Rust DB / db-queries (push) Has been cancelled
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled

This commit is contained in:
Mrinal Chanshetty 2026-11-05 15:39:40 -08:00
parent 48783a03b2
commit 5e8468c51c
2 changed files with 17 additions and 1 deletions

View file

@ -6,7 +6,7 @@ from typing_extensions import Self
class LDAPSyncSettings(BaseModel):
model_config = ConfigDict(frozen=True, extra="forbid")
model_config = ConfigDict(frozen=True, extra="forbid", hide_input_in_errors=True)
enabled: bool = False
server_url: str = ""

View file

@ -242,6 +242,22 @@ def test_invalid_configuration_is_rejected(updates: Mapping[str, object]):
LDAPSyncSettings.model_validate({**SETTINGS.model_dump(), **updates})
@pytest.mark.parametrize(
"updates,message",
[
({"bind_dn": "cn=admin", "start_tls": False}, "require TLS"),
({}, "bind_dn and bind_password must be configured together"),
],
)
def test_invalid_configuration_errors_do_not_expose_bind_password(updates: Mapping[str, object], message: str):
password: Final = "qa-secret-42"
with pytest.raises(ValidationError, match=message) as error:
LDAPSyncSettings.model_validate(
{**SETTINGS.model_dump(exclude_unset=True), **updates, "bind_password": password}
)
assert password not in str(error.value)
def test_cancelled_reader_stops_before_opening_ldap():
cancellation = Event()
cancellation.set()