What's up guys. We all know most important feature in every application is authentication. To make that authentication much more secured and make b...
For further actions, you may consider blocking this person and/or reporting abuse
NOT SECURE AT ALL.
You are sending Refresh token with response and you are expecting the refresh token from body? You need to understand that this method is basically the worst way of doing it. So many things are wrong with your codes, but most important thing:
You should send the refresh token as httpOnly secure cookie with proper sameSite.
And when you want to get a new access token, inside your refresh controller you get the refresh token from cookie (
req.cookies.jwt
) and then verify it.Dear author, you can't just write some article about this topics if you are not professional at it.
Totally agree with Farzin. In your solution refresh token decreases security of the system? Refresh token can be compromised with the same probability as access token (because they both reside in the same place - body) and at the same time refresh token has a way longer lifetime. That's absolutely decreases security.
clearly, you @farzindev and @volodymyrmatselyukh see lots of problems in this implementation. why don't you guys write better implementations addressing those issues?
still, @cyberwolves 's article is a good reference for those unaware of how to handle such cases.
chill man :v
He is right. Security is a serious topic... only experts in the field should be teaching it with actual best practices.
yeah I know man, you gotta chill or this site will become the next stackoverflow
Thank you @cyberwolves for your comprehensive documentation.
Let me get this straight:
Can you make an article about the frontend part using react
If I understood correctly you can not be logged in on multiple devices because there is only one refresh token per user?
It's a different aspect, refreshToken only helps you secure the application more properly compare to using 1 accessToken. If you want to restrict one user per device, you need to save users' info whenever they log in and confront it with newer info.
what is the purpure of refresh Token, when you have to have only accessToken and you store refresh token
Refresh token is used to obtain a new access token (short lived) when it is expired instead of using user/password. Refresh token has a longer life time.