improve logging of LDAP login process even more (#529)
Some checks failed
Docker / Build and Push (push) Has been cancelled
github-pages / deploy (push) Has been cancelled
Docker / release (push) Has been cancelled

This commit is contained in:
Christoph Haas
2025-09-24 18:39:45 +02:00
parent b122e1ae60
commit cc2d1f53c4
2 changed files with 10 additions and 4 deletions

View File

@@ -374,13 +374,15 @@ func (a *Authenticator) passwordAuthentication(
rawUserInfo, err := ldapAuth.GetUserInfo(context.Background(), identifier) rawUserInfo, err := ldapAuth.GetUserInfo(context.Background(), identifier)
if err != nil { if err != nil {
if !errors.Is(err, domain.ErrNotFound) { if !errors.Is(err, domain.ErrNotFound) {
slog.Warn("failed to fetch ldap user info", "identifier", identifier, "error", err) slog.Warn("failed to fetch ldap user info",
"source", ldapAuth.GetName(), "identifier", identifier, "error", err)
} }
continue // user not found / other ldap error continue // user not found / other ldap error
} }
ldapUserInfo, err = ldapAuth.ParseUserInfo(rawUserInfo) ldapUserInfo, err = ldapAuth.ParseUserInfo(rawUserInfo)
if err != nil { if err != nil {
slog.Error("failed to parse ldap user info", "identifier", identifier, "error", err) slog.Error("failed to parse ldap user info",
"source", ldapAuth.GetName(), "identifier", identifier, "error", err)
continue continue
} }
@@ -393,13 +395,14 @@ func (a *Authenticator) passwordAuthentication(
} }
if userSource == "" { if userSource == "" {
slog.Warn("no user source found for user", "identifier", identifier, "ldapProviderCount", a.ldapAuthenticators) slog.Warn("no user source found for user",
"identifier", identifier, "ldapProviderCount", len(a.ldapAuthenticators), "inDb", userInDatabase)
return nil, errors.New("user not found") return nil, errors.New("user not found")
} }
if userSource == domain.UserSourceLdap && ldapProvider == nil { if userSource == domain.UserSourceLdap && ldapProvider == nil {
slog.Warn("no ldap provider found for user", slog.Warn("no ldap provider found for user",
"identifier", identifier, "ldapProviderCount", a.ldapAuthenticators) "identifier", identifier, "ldapProviderCount", len(a.ldapAuthenticators), "inDb", userInDatabase)
return nil, errors.New("ldap provider not found") return nil, errors.New("ldap provider not found")
} }

View File

@@ -113,10 +113,13 @@ func (l LdapAuthenticator) GetUserInfo(_ context.Context, userId domain.UserIden
} }
if len(sr.Entries) == 0 { if len(sr.Entries) == 0 {
slog.Debug("LDAP user not found", "source", l.GetName(), "userId", userId, "filter", loginFilter)
return nil, domain.ErrNotFound return nil, domain.ErrNotFound
} }
if len(sr.Entries) > 1 { if len(sr.Entries) > 1 {
slog.Debug("LDAP user not unique",
"source", l.GetName(), "userId", userId, "filter", loginFilter, "entries", len(sr.Entries))
return nil, domain.ErrNotUnique return nil, domain.ErrNotUnique
} }