Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proper logging for ldap auth requests #1008

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/sane-ldap-auth-logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Use proper logging for ldap auth requests

Instead of logging to stdout we now log using debug level logging or error level logging in case the configured system user cannot bind to LDAP.

https://github.com/cs3org/reva/pull/1008
6 changes: 3 additions & 3 deletions pkg/auth/manager/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (am *mgr) Authenticate(ctx context.Context, clientID, clientSecret string)
// First bind with a read only user
err = l.Bind(am.c.BindUsername, am.c.BindPassword)
if err != nil {
log.Error().Err(err).Msg("bind with system user failed")
return nil, err
}

Expand All @@ -142,13 +143,12 @@ func (am *mgr) Authenticate(ctx context.Context, clientID, clientSecret string)
return nil, errtypes.NotFound(clientID)
}

log.Debug().Interface("entries", sr.Entries).Msg("entries")

userdn := sr.Entries[0].DN

// Bind as the user to verify their password
err = l.Bind(userdn, clientSecret)
if err != nil {
log.Debug().Err(err).Interface("userdn", userdn).Msg("bind with user credentials failed")
return nil, err
}

Expand All @@ -164,7 +164,7 @@ func (am *mgr) Authenticate(ctx context.Context, clientID, clientSecret string)
Mail: sr.Entries[0].GetEqualFoldAttributeValue(am.c.Schema.Mail),
DisplayName: sr.Entries[0].GetEqualFoldAttributeValue(am.c.Schema.DisplayName),
}
fmt.Printf("\n\n\n%+v\n\n\n", u)
log.Debug().Interface("entry", sr.Entries[0]).Interface("user", u).Msg("authenticated user")

return u, nil

Expand Down