4 ms·
One of the drawbacks is that they only really work for specific kinds of sites (e.g. single-page sites, or sites which are utilising a "wizard" workflow). If a
by Someone1234 12y ago
One of the drawbacks is that they only really work for specific kinds of sites (e.g. single-page sites, or sites which are utilising a "wizard" workflow).
If a user would ever open a second tab for your site then that entire model breaks down (as they would have to re-authenticate each and every time). Ditto every time a user leaves and returns.
For example, if you ran a shopping site this kind of token-based tracking would work fine for the checkout wizard-workflow, but not really for the actual store (e.g. recommendations, shopping basket, dynamic shipping calculation based on location, etc).
It definitely has its uses. But those uses are still highly limited.
- dmix 12y agoTokens are typically stored in localStorage, so the app doesn't have to be a single-page app. I'd still force reauth before important events such as credit card purchases or changing email addresses but returning users or opening a new tab session does not require reauth.
- jerf 12y agoIf tokens are automatically stored in localStorage and automatically pulled out of it, aren't you right back to being open to CSRF? That doesn't seem meaningfully different than cookies.
- dmix 12y agoHow can they do that via CSRF? The attacker would need access to javascript on the victim page to have the token pulled from localStorage, append the token to the request in order to successfully submit a form. This is protected via SOP. GET requests do not return the localStorage data... nor do GET request modify any data, unless poorly programmed. Form POST requests that get submitted by an attacker are missing the token in the request, where with cookies it gets appended automatically. Token auth is vulnerable to XSS attacks, but not CSRF. So additional precautions can be added. But I do tend to agree with Egor Homakov where XSS is a serious risk to use auth token stored via httpOnly cookie: https://twitter.com/homakov/status/298744658706714624 https://twitter.com/homakov/status/298744658706714624