Skip to content

Commit 9a7fb5c

Browse files
Improve LDAP fallback logging and handling based on PR feedback
1 parent 5b38415 commit 9a7fb5c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

cps/progress_syncing/protocols/kosync.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,15 @@ def authenticate_user() -> Optional[ub.User]:
176176
if login_result:
177177
log.info(f"authenticate_user: Successfully authenticated user via LDAP: {user.name}")
178178
return user
179-
if error is not None:
180-
log.error(f"authenticate_user: LDAP error for user {user.name}: {error}")
181-
# Fall through to local password check for local users when LDAP is configured
179+
180+
# Log LDAP failure but continue to local check (fallback)
181+
# We use debug level here because failure is expected if the user is using a local password
182+
if error:
183+
log.debug(f"authenticate_user: LDAP authentication failed for {user.name} (attempting local fallback): {error}")
182184

183185
# Verify password using constant-time comparison
184-
if check_password_hash(str(user.password), password):
186+
# Check if user has a local password set before attempting verification
187+
if user.password and check_password_hash(str(user.password), password):
185188
log.info(f"User authenticated successfully: {username}")
186189
return user
187190

0 commit comments

Comments
 (0)