From 9ef4200be023bec139c16edb37eb4d0139b330da Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sat, 27 Feb 2021 00:13:48 +0100 Subject: [PATCH] fix ldap provider, disable gin logs by default --- internal/authentication/providers/ldap/provider.go | 6 +++--- internal/server/server.go | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/authentication/providers/ldap/provider.go b/internal/authentication/providers/ldap/provider.go index 7e6dc55..f113696 100644 --- a/internal/authentication/providers/ldap/provider.go +++ b/internal/authentication/providers/ldap/provider.go @@ -86,7 +86,7 @@ func (provider Provider) Login(ctx *authentication.AuthContext) (string, error) } if len(sr.Entries) != 1 { - return "", errors.Wrapf(err, "invalid amount of ldap entries (%d)", len(sr.Entries)) + return "", errors.Errorf("invalid amount of ldap entries (%d)", len(sr.Entries)) } userDN := sr.Entries[0].DN @@ -97,11 +97,11 @@ func (provider Provider) Login(ctx *authentication.AuthContext) (string, error) switch provider.config.Type { case ldapconfig.TypeActiveDirectory: if ldapconfig.IsActiveDirectoryUserDisabled(uac) { - return "", errors.Wrapf(err, "user is disabled") + return "", errors.New("user is disabled") } case ldapconfig.TypeOpenLDAP: if ldapconfig.IsOpenLdapUserDisabled(uac) { - return "", errors.Wrapf(err, "user is disabled") + return "", errors.New("user is disabled") } } } diff --git a/internal/server/server.go b/internal/server/server.go index 096c7e0..8bb6f38 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -97,7 +97,10 @@ func (s *Server) Setup(ctx context.Context) error { gin.SetMode(gin.DebugMode) gin.DefaultWriter = ioutil.Discard s.server = gin.New() - s.server.Use(ginlogrus.Logger(logrus.StandardLogger()), gin.Recovery()) + if logrus.GetLevel() == logrus.TraceLevel { + s.server.Use(ginlogrus.Logger(logrus.StandardLogger())) + } + s.server.Use(gin.Recovery()) s.server.SetFuncMap(template.FuncMap{ "formatBytes": common.ByteCountSI, "urlEncode": url.QueryEscape,