8 ms·
I respectfully disagree. (Full disclosure: I'm the author of the post and work at a company with software that produces a lot of JWTs.) Like any tool, JWT can
by mooreds 5y ago
I respectfully disagree. (Full disclosure: I'm the author of the post and work at a company with software that produces a lot of JWTs.)
Like any tool, JWT can be misused and you can do insecure things with it. I actually quote @tptacek in a different article about JWTs: https://fusionauth.io/learn/expert-advice/tokens/building-a-secure-jwt https://fusionauth.io/learn/expert-advice/tokens/building-a-...
However, JWTs have strengths too. They are:
* flexible
* widely supported
* standardized
* stateless
* portable
* relatively easy to understand
* extendable
They also have libraries (often open source) to help you generate and consume them in almost every programming language, which is a huge help when it comes to using a tool securely.
Edit: fixed typo (relative -> relatively).
- merlincorey 5y agoWhy not PASETO?
- mooreds 5y agoWidespread support is the biggest obstacle to PASETO adoption. Classic chicken and egg problem. I am also not aware of it being standardized (a brief google shows it is in progress, which is nice). Other than that, it seems nice. A better JWT than JWT with some of the sharp edges removed. I've actually filed an issue for our product to support PASETO and it's gotten some community support, but not an overwhelming amount.
- deleted 5y ago[deleted]
- Sohcahtoa82 5y ago> stateless This is a bug, not a feature, especially if you make your tokens long-lived. If your implementation is completely stateless, then there's no way to invalidate a token to allow a user to log out. If a JWT somehow gets stolen, the user has no way to terminate the stolen session. At best, you could create a blacklist of tokens that have been invalidated, which would delete rows as time goes on and the tokens reach their natural expiration date to avoid the database growing forever. But at that point, it's no longer stateless.
- mooreds 5y ago> especially if you make your tokens long-lived Agreed! You should never make tokens long lived. Seconds to minutes is what we typically see. "But won't users have to log in whenever the token expires?" Nope, that's what the refresh grant (in the OAuth world) is for. I am not as familiar with other uses of JWT, but I suspect there is a similar process that relies on the issuer for them. > But at that point, it's no longer stateless. Agreed, it is an architectural choice. You can choose the benefits of statelessness (scale) at a cost of revocation difficulties. You can get revocation, but you have to re-introduce state. Is there some token solution out that that I'm unaware of that gives you statelessness and revocation? Would love to learn more about it if so.
- tptacek 5y agoThe refresh grant is itself a long-lived, difficult-to-revoke token. TANSTAAFL.
- daveidol 5y agoJust like a session cookie is long-lived? At least with a refresh token you can keep things like specific roles etc. out of it and treat it much like an opaque session cookie (perhaps just containing nothing but the user's ID, which can be looked up to get the real roles/permissions for the short-lived access tokens). I think it's dubious to call refresh tokens "difficult-to-revoke" but call sessions easy to revoke. Both require some kind of state. The difference is that you are (hopefully) doing far more grants and checks on tokens than you are doing revokes - so why not optimize for that flow?
- JamesSwift 5y agoSession cookies are just a password for the server to lookup the information _on its side_. So when you revoke the server's portion of the session, it no longer exists even though the cookie is "valid".
- 5y ago