Tangential question: what is the best practice for handling authentication on a SPA? I have seen JWT being heavily criticized on HN and elsewhere. What is the alternative that still maintains the separation between front- and back-end?
Like anything else it depends. JWTs are still great. Just don’t treat it like a classical session and dump important information in it. You could also use session like you always have if the SPA is being served by the same server.
The big issue I have with JWT is they are hard to invalidate for security reasons, but if you lower the validity and refresh the token more often you can mitigate (not eliminate) the risk.