mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-26 20:01:21 +08:00
improve logging of LDAP login process even more (#529)
This commit is contained in:
@@ -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")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user