-
While working on the vue migration for 2.0, I was having trouble finding a sane way of dealing with CSRF tokens in a single page application. With bearer tokens, you don't need to use CSRF tokens. Additionally, this would remove the need to managing sessions, and allow us to write endpoints in the server that are stateless (think REST). Writing the server in a restful way opens up more options for exposing the API as mentioned in one of the improvement ideas. With a JWT, we can keep the expiry time short and use refresh tokens. Additionally, we could easily add logic to the front end to log the user out, and prevent the CSRF logout bug. Does anyone have thoughts on this before I get too deep into it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I've explored this a bit further, and I'm pretty confident this is the way to go for Threat Dragon Web.
The implementation uses a refresh token flow. The timeouts and some other options will likely wind up being configurable with some sane defaults (5 minutes for access token, 6 hours for refresh). When the JWT expires, the front-end will automatically attempt to get a new token using the refresh token and retry the original request. As far as user experience is concerned, this should be a seamless transition. I'm still very much open to differing opinions, but wanted to share what I've learned so far. |
Beta Was this translation helpful? Give feedback.
I've explored this a bit further, and I'm pretty confident this is the way to go for Threat Dragon Web.
Some of the other benefits I've realized after exploring the implementation a bit more: