1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

feat(logging): replace all the loggers with zerolog EE-4186 (#7663)

This commit is contained in:
andres-portainer 2022-09-16 13:18:44 -03:00 committed by GitHub
parent 53025178ef
commit 36e7981ab7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
109 changed files with 1101 additions and 662 deletions

View file

@ -2,17 +2,18 @@ package auth
import (
"errors"
"log"
"net/http"
"strings"
"github.com/asaskevich/govalidator"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
portainer "github.com/portainer/portainer/api"
httperrors "github.com/portainer/portainer/api/http/errors"
"github.com/portainer/portainer/api/internal/authorization"
"github.com/asaskevich/govalidator"
"github.com/rs/zerolog/log"
)
type authenticatePayload struct {
@ -31,9 +32,11 @@ func (payload *authenticatePayload) Validate(r *http.Request) error {
if govalidator.IsNull(payload.Username) {
return errors.New("Invalid username")
}
if govalidator.IsNull(payload.Password) {
return errors.New("Invalid password")
}
return nil
}
@ -101,6 +104,7 @@ func (handler *Handler) authenticateInternal(w http.ResponseWriter, user *portai
}
forceChangePassword := !handler.passwordStrengthChecker.Check(password)
return handler.writeToken(w, user, forceChangePassword)
}
@ -125,7 +129,7 @@ func (handler *Handler) authenticateLDAP(w http.ResponseWriter, user *portainer.
err = handler.addUserIntoTeams(user, ldapSettings)
if err != nil {
log.Printf("Warning: unable to automatically add user into teams: %s\n", err.Error())
log.Warn().Err(err).Msg("unable to automatically add user into teams")
}
return handler.writeToken(w, user, false)
@ -191,6 +195,7 @@ func teamExists(teamName string, ldapGroups []string) bool {
return true
}
}
return false
}
@ -200,6 +205,7 @@ func teamMembershipExists(teamID portainer.TeamID, memberships []portainer.TeamM
return true
}
}
return false
}