mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 17:06:57 -06:00
AuthN: Tune logs in client (#65714)
* AuthN: Remove log * AuthN: Check for user not found error in hook
This commit is contained in:
parent
94cc93cc83
commit
355f47628f
@ -40,6 +40,11 @@ var (
|
|||||||
"user.sync.fetch",
|
"user.sync.fetch",
|
||||||
errutil.WithPublicMessage("Insufficient information to authenticate user"),
|
errutil.WithPublicMessage("Insufficient information to authenticate user"),
|
||||||
)
|
)
|
||||||
|
errFetchingSignedInUserNotFound = errutil.NewBase(
|
||||||
|
errutil.StatusUnauthorized,
|
||||||
|
"user.sync.fetch-not-found",
|
||||||
|
errutil.WithPublicMessage("User not found"),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
func ProvideUserSync(userService user.Service,
|
func ProvideUserSync(userService user.Service,
|
||||||
@ -114,6 +119,9 @@ func (s *UserSync) FetchSyncedUserHook(ctx context.Context, identity *authn.Iden
|
|||||||
OrgID: r.OrgID,
|
OrgID: r.OrgID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, user.ErrUserNotFound) {
|
||||||
|
return errFetchingSignedInUserNotFound.Errorf("%w", err)
|
||||||
|
}
|
||||||
return errFetchingSignedInUser.Errorf("failed to resolve user: %w", err)
|
return errFetchingSignedInUser.Errorf("failed to resolve user: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,6 @@ func (s *JWT) Authenticate(ctx context.Context, r *authn.Request) (*authn.Identi
|
|||||||
|
|
||||||
sub, _ := claims["sub"].(string)
|
sub, _ := claims["sub"].(string)
|
||||||
if sub == "" {
|
if sub == "" {
|
||||||
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")
|
return nil, errJWTMissingClaim.Errorf("missing mandatory 'sub' claim in JWT")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,6 @@ func (s *Session) Authenticate(ctx context.Context, r *authn.Request) (*authn.Id
|
|||||||
|
|
||||||
token, err := s.sessionService.LookupToken(ctx, rawSessionToken)
|
token, err := s.sessionService.LookupToken(ctx, rawSessionToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log.FromContext(ctx).Warn("Failed to look up session from cookie", "error", err)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user