| Reasons why JWTs are not awesome: - to revoke a JWT you have to blacklist it in the database so it still requires a database call to check if it's valid. - JWT are to prevent database calls but a regular request will still hit the database anyway. - JWT are very large payloads passed around in every request taking up more bandwidth. - If user is banned or becomes restricted then it still requires database calls to check the state of user. - JWT spends CPU cycles verifying signature on every request. - JWTs just aren't good as session tokens which is how a lot of web developers try to use them as. Use a session ID instead. Where JWT works best: - when a client can interact with multiple services and each service doesn't need to do a network request to verify (ie federated protocols like OpenID). The client verifies the user's identity via the 3rd party. - as a 1 time use token that's short lived, such as for downloading files where user gets a token requested from auth server and then sends it to the download server. |
Once you go down the path of checking a DB along side the JWT your design has gone off the rails. Either the expiry works for you or it doesn't. Don't try to "fix" it.