-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jwt iat & exp #11
Comments
This is not related to your suggestion. How could we implement Redis to store RefreshToken from this tutorial? |
@jonnymholt Thanks for bringing this up. If you want to submit a pull request I will merge into the main branch :) |
@jonnymholt Thanks for sharing the solution I needed it thanks @zachgoll for everything |
You don't need to explicitly include
Taken from here: https://www.npmjs.com/package/jsonwebtoken |
Hi I just wanted to highlight something as well as suggest the fix should it be wanted.
In the issueJWT function in your utils.js file, the payload sets the iat key to
Date.now()
. This isn't correct as it sets iat to milliseconds representation, rather than seconds. It also creates an issue in that the jwt sign function uses expiresIn '1d'. This in turn is not then set correctly, based upon the iat date being issued in the distant future. It does not seem to generate a jwt that has valid iat or exp claims when you check it on jwt.io, and it doesn't expire the jwt's authorizaton as expected the following day.The solution is to amend the payload to set the iat to seconds as such:
This then sets the iat, and more importantly the exp claims correctly so that the jwt correctly expires as checked by passport.
Hope this helps
The text was updated successfully, but these errors were encountered: