Don't use JSON web tokens for sessions
1–10 of 153 posts
Re: Don't use JSON web tokens for sessions
#2Re: Don't use JSON web tokens for sessions
#3Re: Don't use JSON web tokens for sessions
#4Re: Don't use JSON web tokens for sessions
#5https://stormpath.com/blog/where-to-store-your-jwts-cookies-...
But then, I'm now even more confused as the others here. How exactly am I supposed to secure my REST API now?
Re: Don't use JSON web tokens for sessions
#6How else would you do it if your backend is a REST API and you want to keep it RESTful? JWT seemed like a good solution until I read this.
I however disagree with most of the points made in the article, and use stateless JWT myself.
Re: Don't use JSON web tokens for sessions
#7Re: Don't use JSON web tokens for sessions
#8I think Armin Ronacher's blog post[0] is a good overview on the benefits of using signed client storage for session state.
[0]: http://lucumr.pocoo.org/2013/11/17/my-favorite-database/
Re: Don't use JSON web tokens for sessions
#9That way the front end can pass the token to the back end, I can authenticate and authorize using the redis data (I could store more data in redis, but instead I hit postgres for any other data about the user, such as admin roles, when needed during the authorization process).
It's true that this doesn't make you invincible to CSRF or XSS - any attacker who goes through the trouble and gets access to the token via MITM (although I only use HTTPS, that's not a guarantee) or by injecting javascript in the webapp itself (through user-editable content from a malicious user), that attacker suddenly has full access to the user's account. Still, it's a pretty reasonable way to deal with session problems.
I also set expiry timeouts on these tokens and can delete them manually if a user wants to end all sessions (say on password change). Deleting by value match isn't super-straightforward in redis, but it's also possible with a bit of LUA.
Re: Don't use JSON web tokens for sessions
#10How else would you do it if your backend is a REST API and you want to keep it RESTful? JWT seemed like a good solution until I read this.
You would do it by adding a Redis server that stores stateful sessions (mentioned in the article). I however disagree with most of the points made in the article, and use stateless JWT myself.