| JWTs have made client side auth integrations look better. But the problem is that common security considerations and implementation details are generally overlooked. 1. Tokens are typically stored in localStorage. (app becomes vulnerable to CSRF & XSS attacks). 2. Tokens can be stolen. Now this is generally controlled by having a very short expiration time. 3. Short expiration times mean persisting refresh tokens to do a silent refresh. 4. Blacklisting of tokens adds complexity and defeats the purpose of decentralising the auth workflow. 5. There's technically no logout. It's all done via very short expiration times. With multiple tabs open, logging out on one tab needs to be synced with rest of the tabs via some event listeners. 6. SSR rendered pages need to send along the latest refresh token cookie so that the browser can use it. 7. The refresh token is sent by the auth server to the client as an HttpOnly cookie to prevent XSS/CSRF. My colleagues wrote a detailed guide which goes through these considerations - https://hasura.io/blog/best-practices-of-using-jwt-with-grap... |