-
Notifications
You must be signed in to change notification settings - Fork 270
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
Bcryptjs compares badly with jwt and its hash #137
Comments
Same error! Comparing always returns true |
@JYachelini In my opinion it happens because the output hash is too short comparing with jwt token, therefore we get collisions |
Hello @Fumarie, sorry I did not answer, but I found what argon2, a dependency to encrypt data, does not have this problem. And I realized what this problem occurs with NestJS, at least to me it happened only with NestJS. |
I correct myself, it happens without Nest. |
Experiencing the same issue. I have tried both |
Hello! I'm comparing a Refresh token Hash with another Refresh token and it returns true when it should return false.
The refresh token hash is stored in the DB in the User collection. When I send a refresh token through a client it compares this refresh token with the refresh token hash and always return true.
The first comparation compares is fine because they are the same token. But when this process finishes it is not the same, it always saves a new refresh token hash in the DB. So ONLY in the first comparision it has to return true.
Steps:
Log in and returns 2 tokens, access token and refresh token.
Refresh the tokens with the refresh token I got from the login. It returns two new tokens. So the refresh token in the DB has change, it is not the same when I log in.
Refresh the token again with the SAME tokenI obtained in step 1.
This means the comparition is true.
Code:
Please notify me if I'm wrong and this comparision is correct. And tell me if I have explained myself wrong, English is not my first language and it's a bit difficult to me haha.
The text was updated successfully, but these errors were encountered: