6 ms·
A big limitation is forced early expiration. If you need to do that then you end up needing to share expiration information and therefore need to share somethin
by xnorswap 5y ago
A big limitation is forced early expiration. If you need to do that then you end up needing to share expiration information and therefore need to share something that might as well be a password hash.
So for example it's not great to use instead of a session key. You could design a system where you have, say, 6 API endpoints and instead of the API endpoints needing access to the authentication db, you use bearer tokens from a single sign on to grant access to the API.
That works great until Bob realizes that Eve has got access to his password and hits a password reset to force Eve out the system.
But with bearer tokens, Eve still has access until those tokens expire.
You could add a check for expiration against the calls, but then we're back to session keys being more straightforward because we're back to having some central information (has Bob's token expired) that needs propagation to the different services.
You could have extremely short expiration but then you're back to having to round-trip to re-authenticate often (or in an auto-refresh situation, one where you're back to checking for expiration yet again).
I think bearer tokens work best for internal proxies / APIs to avoid hitting the data store, they aren't a great replacement for session keys.
- mormegil 5y agoYeah, there is this classic: http://cryto.net/~joepie91/blog/2016/06/19/stop-using-jwt-for-sessions-part-2-why-your-solution-doesnt-work/ http://cryto.net/~joepie91/blog/2016/06/19/stop-using-jwt-fo...
- spacemanmatt 5y agoLong-time fan of joepie. Worth a follow.
- eurasiantiger 5y ago> You could have extremely short expiration but then you're back to having to round-trip to re-authenticate often (or in an auto-refresh situation, one where you're back to checking for expiration yet again). GraphQL clients like Apollo can solve this by re-authenticating transparently on error and reissuing the same request.
- ledauphin 5y agoI would accept this argument if I had ever in my career run across a case where somebody discovered that their token was stolen and reported that within an hour. I grant that this can happen at scale, e.g. Dropbox, or for sensitive systems that give mutating access to financial instruments, but for the _vast_ majority of businesses, this is a completely hypothetical problem.