Skip to content

Commit

Permalink
Added nil check for token validation (litmuschaos#4727)
Browse files Browse the repository at this point in the history
Signed-off-by: Saranya-jena <saranya.jena@harness.io>
  • Loading branch information
Saranya-jena authored Jun 25, 2024
1 parent 17085b4 commit 5e52f7f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions chaoscenter/authentication/api/handlers/grpc/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ func (s *ServerGrpc) ValidateRequest(ctx context.Context,
return &protos.ValidationResponse{Error: err.Error(), IsValid: false}, err
}
claims := token.Claims.(jwt.MapClaims)

if claims["uid"] == nil {
return &protos.ValidationResponse{Error: "token is invalid", IsValid: false}, err
}

uid := claims["uid"].(string)
err = validations.RbacValidator(uid, inputRequest.ProjectId,
inputRequest.RequiredRoles, inputRequest.Invitation, s.ApplicationService)
Expand Down

0 comments on commit 5e52f7f

Please sign in to comment.