Stop using JSON Web Tokens for user sessions
21–30 of 145 posts
Re: Stop using JSON Web Tokens for user sessions
#22Re: Stop using JSON Web Tokens for user sessions
#23It would be helpful if the post not only told you what to _not_ do (especially when it is a frequently done thing) but offered any sort of alternative.
Edit: yeah sure downvote me into oblivion. I'm not throwing away perfectly functional equipment because it doesn't support the latest and greatest ciphersuite. I'm also not planning on a being a roadblock on everything, it's balancing act.
Re: Stop using JSON Web Tokens for user sessions
#24As a side question (or rather, what I expected the central point of the article to be instead): how are you supposed to actually use JWT? The point of JWT vs opaque tokens is that you can just inspect the token itself to derive permissions without hitting any sessions in DB, right? This means we need a short-lived access token (5 min or so?) so that sessions are revoked in a reasonable time if the token is stolen som…
Re: Stop using JSON Web Tokens for user sessions
#25It's interesting how much of an upward hill battle it has been for me to argue that JWT tokens need to be stored in cookies rather than LocalStorage. In my latest project, the lead backend dev is convinced it is insecure to store the accessToken in a HTTPOnly cookie, and that it HAS to be stored in LocalStorage.
But aren't HTTPonly coookies stored in a SQLite db, and have no password attached in Firefox or Chrome?
localStorage is totally accessible to any JavaScript running on the page, so your session can be completely hijacked and used later.
Re: Stop using JSON Web Tokens for user sessions
#26In my opinion there are 2 good approaches: If you really need to use JWT-s then store the refresh (just normal UUID looking token that is validated on the backend) token in a httpOnly cookie and JWT in local/session storage, use 10-15 minutes expiration and you are somewhat OK on logout= (the XSS is still maybe exploitable). On logout make sure to invalidate the refresh token. In my opinion a better way is to just us…
Why does the length matter compared to when they are sent with cookies or with a special header?
Re: Stop using JSON Web Tokens for user sessions
#27Make sure your app is actually using a JWT framework, not a lesser version, and implements basic security practices.
Re: Stop using JSON Web Tokens for user sessions
#28As a side question (or rather, what I expected the central point of the article to be instead): how are you supposed to actually use JWT? The point of JWT vs opaque tokens is that you can just inspect the token itself to derive permissions without hitting any sessions in DB, right? This means we need a short-lived access token (5 min or so?) so that sessions are revoked in a reasonable time if the token is stolen som…
Your refresh token does not need to be a JWT, it needs to be checked once in a blue moon and a server side round trip is OK
Re: Stop using JSON Web Tokens for user sessions
#29Re: Stop using JSON Web Tokens for user sessions
#30In the following Stackoverflow thread (https://stackoverflow.com/a/60941643) I described a way to store a JWT in Cookies while keeping convenient to use payload from the Javascript stack (for instance to display the user name).
This is achieved by splitting the JWT in 3 parts (header, payload and signature) and storing it into 3 different Cookies which have different properties. The _header_ and _payload_ would be accessible from the web application while the _signature_ is configured with HttpOnly and therefore unaccessible from the web app. The inconvenient of this method is that you have to reconstruct/concat the 3 parts server side.
Disclaimer: it's actually an experiment which has for purpose to get the better of both world and it has not been tested from security standpoint.