Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
crlssn committed Oct 17, 2024
1 parent d484a60 commit ee8032e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion go/pkg/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,13 @@ func (m *Manager) ValidateAccessToken(token string) error {
return fmt.Errorf("parsing claims: %w", err)
}

if err = m.Validator.Validate(claims); err != nil {
if err = m.ValidateClaims(claims); err != nil {
return fmt.Errorf("validating claims: %w", err)
}

return nil
}

func (m *Manager) ValidateClaims(claims *Claims) error {
return m.Validator.Validate(claims)
}
5 changes: 5 additions & 0 deletions go/rpc/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ func (h *handler) RefreshToken(ctx context.Context, req *connect.Request[v1.Refr
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("invalid refresh token"))
}

if err = h.jwt.ValidateClaims(claims); err != nil {
log.Error("token validation failed", zap.Error(err))
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("invalid refresh token"))
}

accessToken, err := h.jwt.CreateToken(claims.UserID, jwt.TokenTypeAccess)
if err != nil {
log.Error("token generation failed", zap.Error(err))
Expand Down

0 comments on commit ee8032e

Please sign in to comment.