You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue here is when I create a token with jwt.NewWithClaims, my claims are of a type of jwt.RegisteredClaims.
Then I serialise the token to string and parse it with parser.ParseUnverified... - I got claims of pointer type: *jwt.RegisteredClaims.
Why is it important? First of all, it is data inconsistency, which is already not good.
The other issue is when I create a custom Claims type with custom fields, and then in the code trying to typecast to my type, I have to know is a pointer or reference behind the Claims interface of my token. Otherwise, the typecast failed.
What is my suggestion? I suggest refactoring jwt.RegisteredClaims to always be a pointer type.
The text was updated successfully, but these errors were encountered:
Hello dear community.
Here is a sample code that demonstrates the issue:
The issue here is when I create a token with
jwt.NewWithClaims
, my claims are of a type ofjwt.RegisteredClaims
.Then I serialise the token to string and parse it with
parser.ParseUnverified...
- I got claims of pointer type:*jwt.RegisteredClaims
.Why is it important? First of all, it is data inconsistency, which is already not good.
The other issue is when I create a custom Claims type with custom fields, and then in the code trying to typecast to my type, I have to know is a pointer or reference behind the Claims interface of my token. Otherwise, the typecast failed.
What is my suggestion? I suggest refactoring jwt.RegisteredClaims to always be a pointer type.
The text was updated successfully, but these errors were encountered: