Skip to content

Conversation

@ShaysFrame
Copy link

This pull request updates the JWT token handling to use the newer jwt.RegisteredClaims instead of the deprecated jwt.StandardClaims, and improves error message consistency. The main changes are focused on updating the claims structure and token creation logic, as well as standardizing error messages.

JWT Claims Migration:

  • Updated JwtCustomClaims and JwtCustomRefreshClaims structs in domain/jwt_custom.go to use jwt.RegisteredClaims instead of jwt.StandardClaims.

Token Creation Logic:

  • Changed the expiration time assignment in both CreateAccessToken and CreateRefreshToken in internal/tokenutil/tokenutil.go to use jwt.NewNumericDate with jwt.RegisteredClaims. [1] [2]

Error Message Consistency:

  • Standardized error messages to use lowercase in IsAuthorized and ExtractIDFromToken methods in internal/tokenutil/tokenutil.go. [1] [2]
  • Changed the invalid token error message to lowercase in ExtractIDFromToken.
  • jwt.StandardClaims is deprecated: Use RegisteredClaims instead for a forward-compatible way to access registered claims in a struct.

  • error strings should not be capitalized (ST1005)

  • Removed the deprecated StandardClaims and updated to the recommended RegisteredClaims

  • Use jwt.NewNumericDate for expiry fields

- jwt.StandardClaims is deprecated: Use RegisteredClaims instead for a forward-compatible way to access registered claims in a struct.

- Removed the depricated StandardClaims and updated to the recommended RegisteredClaims
- use jwt.NewNumericDate for expiry fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant