-
Notifications
You must be signed in to change notification settings - Fork 188
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
Feat: refresh token for jwt #28
Comments
I've never really understood the concept of sending a refreshToken ; it always reminded me of a super JWT that could get compromised just as well but never had any kind of depreciation. I've read that solution just so many times tough that I cannot say if it's good or bad. I'm going to PR you that in a few because I feel like that what's actually happening. If you have any more intel since then (issue is almost a year old) let me know ! |
edit: that's the oAuth rfc 🔫 :') Here's a proposal PR using a refresh endpoint instead of sending it over & over again. Let me know if you prefer a middleware solution where the refresh_token is sent alongside the access_token. |
What do you think of a solution alike to passport or even node-oidc-provider ? |
@krzepah thanks for your contribution... I will take a look at it within the next week... |
@krzepah Thanks... Yeah, you are right about that being some kind of super token... The thing that makes this a bit more secure is:
this are not perfect solutions, but better than a long living jwt. I worked with passport, but stopped using it (no specific reason)... |
Hi, They are not meant login again, it is up to the client to request the token Refresh. Also, it is not meant to be used again with username and password but with the refreshToken. I didn't want to send it over and over again trough the network uselessly but only when required. That's why I didn't change the Auth.Service because all endpoints are not meant to work as refreshers. The more "difficult" point is understanding when these refreshToken should be completely revoked to not let any "super token" hanging. That proposal reflects more of my "dev tastes" but I understand that you would prefer a service. I'm looking at node-oidc / passport as libs that have made most of the "classic" decisions them selves ; leading into doing less tricky stuff ; Node-oidc-provider requires some custom stuff tough, but I'm definitely getting more into it when I'll get the time. Thanks for your time ! |
Alright, I see... that sounds great, everything that can be spared from a request is good... I'll take a closer look on this one... |
Thanks a lot, if you think it's not such a great idea at all (for whatever reason), i'll implement it just the way you asked o7 |
Currently the access token is valid as long as the expiration time is set to and than the user has to re-authenticate. This means if the token is valid for a long time, and the token gets compromised by a third party this means that this third party can have access as long as they want to a service, unless we change our secret on for the jwt for our service. There are other ways like: blacklisting compromised tokens, but this is only possible if we can check that it is not the real user, that is using this token to get access to our service. So we need to be sure, which is only possible if a user tells us explicitly that this is not him, or we try to create a pattern a for a user, e.g. storing information on
IP
,Location
,OS
,browserinfo
, etc. but this would need additional db request every time a user makes a request.If we used a refresh token, we would send a access token, and a refresh token to the client (maybe as a http only cookie?) and store a relation for the refresh token and a user that uses this refresh token. E.g. in the database or in another mutable store on the server.
The access token expires fast e.g 1 minute, 7 minutes, or longer (depending on the service, security risks, etc). This means there is no additional db call within the time this token is valid, as soon as it expires, we check the refresh token and check if its the same that we stored for our user. if so create a new jwt and refresh token and send it to a user, if not clear the refresh token in the store and the user has to re-authenticate e.g. login with credentials or similar.
something similar like
The text was updated successfully, but these errors were encountered: