Open francescofact opened 4 years ago
Hi, access tokens with long durations are vulnerable to security attacks. Since we are not persisting tokens, they are going to be active during their duration. If an active access token is stolen, it can be used for authentication purposes even though we used http only cookie.
Why access token are vulnerable and refresh token not? It's litteraly the same thing. If you have a refreshtoken you can request an access token.
Hi @francescofact ,
Yes, it is the same thing. This the problem with Native applications and SPAs. This code&article isn't exactly following OAUTH2 standards. If we want to keep users logged in, we need to silently refresh access tokens. This kind of sensitive data should be kept as HttpOnly cookie and this article is related to that specific subject.
Following solutions can be applied to increase security level.
Hi, First of all thank you for this complete example of JWT + httpOnly authentication in Spring. I haven't understand just one thing. Why you use a refreshToken? Why not simply give a longer accessToken? If they stole the accessToken it's difficult that they don't stole also the refreshToken, and with the refreshToken they can have fresh accessTokens for 90 days.
Is there something that i didn't understand? Thank you.