News for hackers. Stuff that matters.
Re:Ask HN: What's the current sentiment on JWT for stateless... by ceejayoz on Friday December 13, 2019 @01:34PM (#21784085)
Frankly, I just went back to sessions.

Everyone thinks they're building the next Facebook, but most of us aren't gonna stress out even a single Redis instance.

Re:Ask HN: What's the current sentiment on JWT for stateless... by jcadam on Friday December 13, 2019 @01:44PM (#21784190)
Yea, I went back to sessions (with Redis) as well. So much simpler, since all of the major web frameworks/libraries have much better support for traditional sessions than JWT...

One place I still might use JWT is in service-to-service auth.

Re:Ask HN: What's the current sentiment on JWT for stateless... by MuffinFlavored on Friday December 13, 2019 @01:38PM (#21784134)
In that same mindset, why not just do a JWT in a cookie then?
Re:Ask HN: What's the current sentiment on JWT for stateless... by schwap on Friday December 13, 2019 @01:39PM (#21784146)
Because then you have all the headaches of JWT, without any of the benefits of stateless auth tokens.
Re:Ask HN: What's the current sentiment on JWT for stateless... by TobiasA on Friday December 13, 2019 @01:45PM (#21784195)
Which headaches would that be?
Re:Ask HN: What's the current sentiment on JWT for stateless... by dewey on Friday December 13, 2019 @02:42PM (#21784670)
That you have to keep a white/blacklist if you want to revoke a token.
Re:Ask HN: What's the current sentiment on JWT for stateless... by mychael on Saturday December 14, 2019 @02:30AM (#21788312)
Blacklisting is only half the problem. Trying to emulate the same UX of regular sessions (staying logged-in etc) is the bigger pain point.
Re:Ask HN: What's the current sentiment on JWT for stateless... by blackflame on Friday December 13, 2019 @01:39PM (#21784140)
Because trusting the client with data is always a risky proposition.
Re:Ask HN: What's the current sentiment on JWT for stateless... by jdminhbg on Friday December 13, 2019 @01:41PM (#21784162)
Sessions are no different in that respect. You need to sign your JWT or session cookie.
Re:Ask HN: What's the current sentiment on JWT for stateless... by bob1029 on Friday December 13, 2019 @02:20PM (#21784486)
I see no reason to sign a session cookie that was issued by and will be validated against some authentication service. Especially if the cookie is sourced from a cryptographically-secure pseudorandom sequence of bytes which is sufficiently long to avoid collisions with other such sequences (e.g. 256 bits of entropy should typically do per session cookie).

In my implementations of such schemes, I will typically feed the CSPRNG output with a time-based salt into SHA256 or SHA512 in order to generate the final token, which is simply stored on both ends (user session db row on server & cookie on client). At this point, the server can simply 1:1 the supplied client token with the row in the database to determine if the session is valid and which claims to return (or which validated final server response to return as the case may be).

Advantages with using a token made out of pure entropy soup are that it's consistent throughout the entire user's session, and confers absolutely zero information regarding the nature of that session. Disadvantages are honestly unclear. I feel like JWT and other stateless schemes started as a bandaid to re-couple the authentication domains of disparate business services, but by way of the various clients.

Re:Ask HN: What's the current sentiment on JWT for stateless... by blackflame7000 on Friday December 13, 2019 @03:34PM (#21785176)
This property you use is known as an ephemeral session key and is a requirement for perfect forward secrecy. (Not being able to crack previous messages by compromising a key in the future)
Re:Ask HN: What's the current sentiment on JWT for stateless... by ceejayoz on Friday December 13, 2019 @01:46PM (#21784202)
You can store data in the server-side session the user is never intended to see. If you want to store that in a JWT, you're going to have to encrypt it, not just sign, and even that may clue them in that something's going on - if you perform some potentially spammy act on a site and suddenly the JWT gets updated with a big encrypted block, you probably know you tripped some flag.
Re:Ask HN: What's the current sentiment on JWT for stateless... by shantly on Friday December 13, 2019 @02:20PM (#21784485)
You can. What does that have to do with traditional sessions?