1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49: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

@ -9,12 +9,12 @@ import (
"net/url"
"strings"
"golang.org/x/oauth2"
portainer "github.com/portainer/portainer/api"
"github.com/golang-jwt/jwt"
"github.com/pkg/errors"
portainer "github.com/portainer/portainer/api"
log "github.com/sirupsen/logrus"
"github.com/rs/zerolog/log"
"golang.org/x/oauth2"
)
// Service represents a service used to authenticate users against an authorization server
@ -31,18 +31,20 @@ func NewService() *Service {
func (*Service) Authenticate(code string, configuration *portainer.OAuthSettings) (string, error) {
token, err := getOAuthToken(code, configuration)
if err != nil {
log.Debugf("[internal,oauth] [message: failed retrieving oauth token: %v]", err)
log.Debug().Err(err).Msg("failed retrieving oauth token")
return "", err
}
idToken, err := getIdToken(token)
if err != nil {
log.Debugf("[internal,oauth] [message: failed parsing id_token: %v]", err)
log.Debug().Err(err).Msg("failed parsing id_token")
}
resource, err := getResource(token.AccessToken, configuration)
if err != nil {
log.Debugf("[internal,oauth] [message: failed retrieving resource: %v]", err)
log.Debug().Err(err).Msg("failed retrieving resource")
return "", err
}
@ -50,9 +52,11 @@ func (*Service) Authenticate(code string, configuration *portainer.OAuthSettings
username, err := getUsername(resource, configuration)
if err != nil {
log.Debugf("[internal,oauth] [message: failed retrieving username: %v]", err)
log.Debug().Err(err).Msg("failed retrieving username")
return "", err
}
return username, nil
}
@ -61,6 +65,7 @@ func mergeSecondIntoFirst(base map[string]interface{}, overlap map[string]interf
for k, v := range overlap {
base[k] = v
}
return base
}
@ -104,6 +109,7 @@ func getIdToken(token *oauth2.Token) (map[string]interface{}, error) {
tokenData[k] = v
}
}
return tokenData, nil
}