From 3dddd3de00093214753d3a18c141d53ff4877db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 27 Jul 2020 12:56:09 +0200 Subject: [PATCH] Use proper logging for ldap auth requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/sane-ldap-auth-logging.md | 5 +++++ pkg/auth/manager/ldap/ldap.go | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 changelog/unreleased/sane-ldap-auth-logging.md diff --git a/changelog/unreleased/sane-ldap-auth-logging.md b/changelog/unreleased/sane-ldap-auth-logging.md new file mode 100644 index 0000000000..58d4c2aca3 --- /dev/null +++ b/changelog/unreleased/sane-ldap-auth-logging.md @@ -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 diff --git a/pkg/auth/manager/ldap/ldap.go b/pkg/auth/manager/ldap/ldap.go index feba0b5980..1e124deac5 100644 --- a/pkg/auth/manager/ldap/ldap.go +++ b/pkg/auth/manager/ldap/ldap.go @@ -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 } @@ -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 } @@ -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