AuthN: cleanup logs (#63652)

* AuthN: clean up logs
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
This commit is contained in:
Karl Persson
2023-02-24 11:26:55 +01:00
committed by GitHub
parent 9cae3f43ed
commit 2a7fc3983b
11 changed files with 57 additions and 69 deletions

View File

@@ -53,13 +53,13 @@ func (s *JWT) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identi
claims, err := s.jwtService.Verify(ctx, jwtToken)
if err != nil {
s.log.Debug("Failed to verify JWT", "error", err)
s.log.FromContext(ctx).Debug("Failed to verify JWT", "error", err)
return nil, errJWTInvalid.Errorf("failed to verify JWT: %w", err)
}
sub, _ := claims["sub"].(string)
if sub == "" {
s.log.Warn("Got a JWT without the mandatory 'sub' claim", "error", err)
s.log.FromContext(ctx).Warn("Got a JWT without the mandatory 'sub' claim", "error", err)
return nil, errJWTMissingClaim.Errorf("missing mandatory 'sub' claim in JWT")
}
@@ -112,7 +112,7 @@ func (s *JWT) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identi
id.IsGrafanaAdmin = isGrafanaAdmin
if id.Login == "" && id.Email == "" {
s.log.Debug("Failed to get an authentication claim from JWT",
s.log.FromContext(ctx).Debug("Failed to get an authentication claim from JWT",
"login", id.Login, "email", id.Email)
return nil, errJWTMissingClaim.Errorf("missing login and email claim in JWT")
}