Re:Ask HN: What's the current sentiment on JWT for stateless...
by jayd16 on Friday December 13, 2019 @02:28PM
(#21784543)
So wait, why does the refresh token not work? Why wouldn't you verify user permissions when generating a new access token?
[ Parent
| on HN ]
Re:Ask HN: What's the current sentiment on JWT for stateless...
by cstrahan on Friday December 13, 2019 @04:38PM
(#21785789)
Remember that the author’s intended audience is developers who want to use JWTs specifically to avoid server side state in the authentication/authorization logic. The point is that, if you want to revoke the refresh token, you have to maintain a blacklist somewhere, and now you’ve contradicted your original goal of avoiding all state, which means that choosing JWT for this particular purpose was illogical, and probably warrants further thought. (TBC, in logic, if your hypothesis leads to a contradiction, then your hypothesis must be false, which is exactly what we’re seeing here in this scenario.)
Re:Ask HN: What's the current sentiment on JWT for stateless...
by kelnos on Saturday December 14, 2019 @02:38AM
(#21788328)
I don't see this as rendering JWTs useless, though. If you have a 10-15 minute validity time, and you only check for revocation on refresh (and perhaps, optionally, on sensitive operations), then you don't have to check the the revoked-tokens table on every request, which means your database doesn't have to scale up nearly as much.
And since the IDs in the revoked-tokens table only matter for the duration of token validity, you can prune the table pretty often, meaning necessary space needed in the DB is relatively small.
It's certainly more complicated than just dealing with stateful session tokens, so you might decide that the trade off isn't worth it, though.
Re:Ask HN: What's the current sentiment on JWT for stateless...
by james_s_tayler on Friday December 13, 2019 @11:04PM
(#21787721)
I disagree. If you make an API Gateway responsible for that concern then it's the only thing that needs to maintain state. The blacklist itself probably kept in something like Redis and the API Gateway just checks against it. Then all downstream services get the benefit of JWT in a "stateless" fashion as advertised. That is, none of the downstream services know or care about any state. They get a request with a JWT and if it has the right claims, it services the request.
Re:Ask HN: What's the current sentiment on JWT for stateless...
by 0x5345414e on Friday December 13, 2019 @10:32PM
(#21787629)
> revoke the refresh token, you have to maintain a blacklist somewhere
Store CreationDate in the refresh token. Store RefreshTokenInvalidBefore in the user record. When refresh is attempted, if Token.CreationDate <= User.RefreshTokenInvalidBefore, reject the refresh. The only drawback here is that it would sign the user out on all devices. However, assuming this is because of a password or token compromise, that's likely the least of their worries.
Re:Ask HN: What's the current sentiment on JWT for stateless...
by msbarnett on Friday December 13, 2019 @02:42PM
(#21784669)
You need a really short refresh cycle for that to be useful to customers. If your customer FooCorp fired Bob, they want to be able to disable his access immediately, not in 3 days when his access token next needs a refresh.