[PR #23] StandardClaims -> RegisteredClaims #23

Open
opened 2026-03-01 14:36:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amitshekhariitbhu/go-backend-clean-architecture/pull/23
Author: @ShaysFrame
Created: 11/27/2025
Status: 🔄 Open

Base: mainHead: fix/tokenutil-jwt-expires


📝 Commits (1)

  • ac72f9d - error strings should not be capitalized (ST1005)

📊 Changes

2 files changed (+11 additions, -10 deletions)

View changed files

📝 domain/jwt_custom.go (+2 -2)
📝 internal/tokenutil/tokenutil.go (+9 -8)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amitshekhariitbhu/go-backend-clean-architecture/pull/23 **Author:** [@ShaysFrame](https://github.com/ShaysFrame) **Created:** 11/27/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/tokenutil-jwt-expires` --- ### 📝 Commits (1) - [`ac72f9d`](https://github.com/amitshekhariitbhu/go-backend-clean-architecture/commit/ac72f9d032a2cdccc33021f6ba251d1e0741c840) - error strings should not be capitalized (ST1005) ### 📊 Changes **2 files changed** (+11 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `domain/jwt_custom.go` (+2 -2) 📝 `internal/tokenutil/tokenutil.go` (+9 -8) </details> ### 📄 Description 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]](diffhunk://#diff-4d726f121f7c84ac5c922e49770be337cc67da6677a579fdf5c3ac9a6b11785dL12-R17) [[2]](diffhunk://#diff-4d726f121f7c84ac5c922e49770be337cc67da6677a579fdf5c3ac9a6b11785dR29-R33) **Error Message Consistency:** * Standardized error messages to use lowercase in `IsAuthorized` and `ExtractIDFromToken` methods in `internal/tokenutil/tokenutil.go`. [[1]](diffhunk://#diff-4d726f121f7c84ac5c922e49770be337cc67da6677a579fdf5c3ac9a6b11785dL46-R47) [[2]](diffhunk://#diff-4d726f121f7c84ac5c922e49770be337cc67da6677a579fdf5c3ac9a6b11785dL59-R60) * 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-backend-clean-architecture#23
No description provided.