dgrijalva / jwt-go

ARCHIVE - Golang implementation of JSON Web Tokens (JWT). This project is now maintained at:
https://github.com/golang-jwt/jwt
MIT License
10.78k stars 997 forks source link

Bug in logic for decoding anything other than MapClaims #458

Open smcallis opened 3 years ago

smcallis commented 3 years ago

https://github.com/dgrijalva/jwt-go/blob/dc14462fd58732591c7fa58cc8496d6824316a82/parser.go#L131

Since this function takes claims as Claims, if you pass anything other than MapClaims{}, you'll get an unmarshalling error: Error verifying token: json: cannot unmarshal object into Go value of type jwt.Claims

Waterdrips commented 3 years ago

https://github.com/dgrijalva/jwt-go/issues/457 this project is unmaintained, I suggest using an alternative

niclasgeiger commented 3 years ago

We also encountered the same issue. This should be the code snippet explaining why this wont work: https://play.golang.org/p/Tf-JYrfmbXO

niclasgeiger commented 3 years ago

ah, if you use &MapClaims{} instead of MapClaims{} it will work. See https://stackoverflow.com/questions/50564341/pointer-to-an-interface-vs-interface-holding-a-pointer-when-unmarshaling-json for more explanations