adding logging for ldap exceptions
This commit is contained in:
1 parent
69cbfa2d3f
commit
6d20db75c5
2 files changed
+6
-4
No files matched your search
@@ -2,6 +2,7 @@ sync:
|
|||||||
uv sync --extra dev
|
uv sync --extra dev
|
||||||
|
|
||||||
seed:
|
seed:
|
||||||
|
uv run alembic upgrade head
|
||||||
uv run python -m scripts.seed
|
uv run python -m scripts.seed
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ blocking the event loop. Login builds the user's DN from
|
|||||||
successful profile is provisioned locally on first sign-in.
|
successful profile is provisioned locally on first sign-in.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from fastapi.concurrency import run_in_threadpool
|
from fastapi.concurrency import run_in_threadpool
|
||||||
@@ -40,10 +42,9 @@ def _bind_and_fetch(username: str, password: str) -> LdapIdentity | None:
|
|||||||
get_info=ldap3.NONE,
|
get_info=ldap3.NONE,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
conn = ldap3.Connection(
|
conn = ldap3.Connection(server, user=user_dn, password=password, auto_bind=True)
|
||||||
server, user=user_dn, password=password, auto_bind=True
|
except LDAPException as e:
|
||||||
)
|
logging.exception("Failed to log into LDAP for user %s", user_dn)
|
||||||
except LDAPException:
|
|
||||||
# Wrong credentials, unreachable server, or a refused bind.
|
# Wrong credentials, unreachable server, or a refused bind.
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user