JWT vs. Opaque Tokens
zitadel.com
JWT vs. Opaque Tokens
1–10 of 101 posts
Re: JWT vs. Opaque Tokens
#2Re: JWT vs. Opaque Tokens
#3I investigated this issue with a customer recently with a focus on revocation. We concluded that if we have to hit the database to check if a JWT token is still valid we can use a session cookie (or equivalent) and hit the database to get the user, the associated capabilities, etc.
That being said, always going to the database for connecting an opaque session token to an identity can quickly become slow, and if those features listed above are not desirable, having a blocklist of revoked JWT IDs in an in-memory cache (like Redis) can bring back some performance benefits.
Re: JWT vs. Opaque Tokens
#4Re: JWT vs. Opaque Tokens
#5I investigated this issue with a customer recently with a focus on revocation. We concluded that if we have to hit the database to check if a JWT token is still valid we can use a session cookie (or equivalent) and hit the database to get the user, the associated capabilities, etc.
You normally do lots of API requests while you are logged in. To services and to download an image for example.
You make sure the current jwt is valid for a few minutes and hit only the database with the refresh token for example.
Only in worst case you really need to block a token and it might be much easier to sync those few tokens in your system into some local cache and let them expire automatically (because you know when they expire as it is contained in the token).
But yes if all of this sounds complicated, use sessions and a distributed redis for your session or just the database.
Re: JWT vs. Opaque Tokens
#6Whats the drawback for just including the ip in jwt and revoke if either time is up or ip change ?
Re: JWT vs. Opaque Tokens
#7I investigated this issue with a customer recently with a focus on revocation. We concluded that if we have to hit the database to check if a JWT token is still valid we can use a session cookie (or equivalent) and hit the database to get the user, the associated capabilities, etc.
Another drawback for JWTs (when used fully statelessly) is the inability to list active sessions on other devices (which may lead to revocation). That being said, always going to the database for connecting an opaque session token to an identity can quickly become slow, and if those features listed above are not desirable, having a blocklist of revoked JWT IDs in an in-memory cache (like Redis) can bring back some pe…
Still very few companies need something like this.
Re: JWT vs. Opaque Tokens
#8Whats the drawback for just including the ip in jwt and revoke if either time is up or ip change ?
Re: JWT vs. Opaque Tokens
#9Whats the drawback for just including the ip in jwt and revoke if either time is up or ip change ?
Re: JWT vs. Opaque Tokens
#10Recommended thought experiment: Every programmer who makes or consumes the tokens in your system needs to attend a meeting about the tokens. Picture that meeting in your head. Was it a huge endeavour, involving several hotels and many months of planning? Then you probably need JWTs. If the meeting could happen in a coffee break then JWTs are wildly inappropriate.