fix ldap provider, disable gin logs by default

This commit is contained in:
Christoph Haas 2021-02-27 00:13:48 +01:00
parent e1c7a43496
commit 9ef4200be0
2 changed files with 7 additions and 4 deletions

View File

@ -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")
}
}
}

View File

@ -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,