Can a single page application store tokens in localStorage?
Yes, of course! LocalStorage is persistent storage, so the token is available to all tabs and windows. It even survives a browser restart.
No, absolutely not! LocalStorage is insecure, and an attacker will be able to steal the token.
Believe it or not, but both answers are correct. As simple as this question is, the answer is far from straightforward. In this session, we dive into the security properties of SPAs. We investigate why localStorage is insecure and discuss potential alternatives. By the end of this session, you will be able to decide where to store tokens in your applications. Even better, you’ll be able to argue why your decision is the right one.