Earlier quoted context omitted.
How the heck did JWT get such a following with issues like these?
This article is propaganda. This is not the first article of its kind; they just keep popping up over and over on HN with the same poor arguments. I usually take the time to write long explanations as to why these points are invalid but I'm tired of arguing with these people. The real reason for these articles I think is that some developers had a very traumatic experience with a poorly implemented JWT authentication…
Stop using JWT for sessions (2016)
181–190 of 255 posts
Re: Stop using JWT for sessions (2016)
#182I'm not 100% sold. I think JWT's are fine in some situations as long as you know the limitations. Regarding session invalidation, I would handle this in two ways. 1. Support a "Log everyone out" function by storing a simple version number in the JWT. If the version constant in your app is different to the number in the JWT, it is invalid. 2. Support a "I need to logout user X function" by storing a blacklist of token…
Re: Stop using JWT for sessions (2016)
#183Earlier quoted context omitted.
This is true, but kicking off a large subset of the userbase every time an account is compromised (or more realistically, every time someone changes their password—which should certainly invalidate their old tokens) isn't going to be a valid trade off for most applications with customers.
You don't have to kick them off. You can make it a trigger to just check whether their session has been invalidated. Store last password change date or something similar, and if the db user is still valid and the password date is older than the JWT creation date, just update the JWT and let them continue. If not, require a new login procedure or deny outright, depending on account status. > every time someone changes…
But, what are you getting for this added complexity--above and beyond what "traditional" user session management provides?
Re: Stop using JWT for sessions (2016)
#184I'm currently in a project where JWT is used. We have a list of searchable items and each one of them holds a gallery of photos - up to 5MB per photo.
The issue at hand is that these photos are served from a certain endpoint which we eventually want to secure, but the back-end's idea here is for the front-end to download the photos via XHR putting the token in the Authorization header - they refuse to send the JWT via cookie saying that it's "incompatible with JWT".
Re: Stop using JWT for sessions (2016)
#185Earlier quoted context omitted.
Yes it does mean something. a session is something that is identified by an ID on the client and is persisted on the server with the corresponding ID. It's a concept. It doesn't have to be stored in a cookie. A session can be represented by a token and stored in any client side storage.
Ok, yes, session is a concept. Session state can be stored in its entirety or split between an ID and body. You can send it all to the client or you can send just an ID and lookup the body on the server. You can send it to the client via the cookie header or via the Authorization header or something else. You can encode the data (sent via cookies or auth header) as a JWT or your own encryption scheme. These are all d…
the storage of session has absolutely nothing to do with the session. I'm not sure why you keep talking about Cookies it has nothing to do with the problem. JWT can be persisted with cookies as well.
Re: Stop using JWT for sessions (2016)
#186Earlier quoted context omitted.
This is true, but kicking off a large subset of the userbase every time an account is compromised (or more realistically, every time someone changes their password—which should certainly invalidate their old tokens) isn't going to be a valid trade off for most applications with customers.
You don't have to kick them off. You can make it a trigger to just check whether their session has been invalidated. Store last password change date or something similar, and if the db user is still valid and the password date is older than the JWT creation date, just update the JWT and let them continue. If not, require a new login procedure or deny outright, depending on account status. > every time someone changes…
The reason for using JWT is that the UI and backend consume the same session object seamlessly. Before what we got in our PHP session and what state we shared with the UI were manually kept in sync through a API request.
Re: Stop using JWT for sessions (2016)
#187Earlier quoted context omitted.
How the heck did JWT get such a following with issues like these?
The article exaggerates these issues. Also there are easy solutions available for those concerns. It's trivial to store a token version on your user object and invalidate any token that has the wrong version.
Re: Stop using JWT for sessions (2016)
#188Earlier quoted context omitted.
Ok, yes, session is a concept. Session state can be stored in its entirety or split between an ID and body. You can send it all to the client or you can send just an ID and lookup the body on the server. You can send it to the client via the cookie header or via the Authorization header or something else. You can encode the data (sent via cookies or auth header) as a JWT or your own encryption scheme. These are all d…
> Ok, yes, session is a concept. Session state can be stored in its entirety or split between an ID and body. the storage of session has absolutely nothing to do with the session. I'm not sure why you keep talking about Cookies it has nothing to do with the problem. JWT can be persisted with cookies as well.
Re: Stop using JWT for sessions (2016)
#189Re: Stop using JWT for sessions (2016)
#190Earlier quoted context omitted.
You don't have to kick them off. You can make it a trigger to just check whether their session has been invalidated. Store last password change date or something similar, and if the db user is still valid and the password date is older than the JWT creation date, just update the JWT and let them continue. If not, require a new login procedure or deny outright, depending on account status. > every time someone changes…
> It's a trade off But, what are you getting for this added complexity--above and beyond what "traditional" user session management provides?