I just noticed a massive flaw with my JWT setup - I have a WebAPI project and am authenticating using JWT as set up in this guide here.
I am sending the users ID to them as part of the token payload. This is so when they can only retrieve resources which are theirs from the API.
The problem I have noticed is the following, if I:
- Call
login()
and get a JWT back from the server - Take the token and decode it on https://jwt.io/
- Change the payload so that the
ID
(that I'm sending to identify the user) is another ID - Use the new Encoded token in an API call
- The token is accepted by the API and can be used to retrieve resources which don't belong to the user.
Why isn't the token invalidated when the user changes the payload - does this not defeat the purpose of the token?