News for hackers. Stuff that matters.
Re:SPAs Are Dead? by pier25 on Wednesday April 07, 2021 @03:03PM (#26729450)
I prefer using cookies, but most SPAs actually use JWTs.
Re:SPAs Are Dead? by jakelazaroff on Wednesday April 07, 2021 @03:11PM (#26729601)
Cookies and JWTs are not alternatives to each other. You can store a JWT in a cookie.
Re:SPAs Are Dead? by shock-value on Wednesday April 07, 2021 @04:27PM (#26730744)
You can also store a JWT in localStorage and require an additional secure signature for it within a cookie (http-only). Best of both worlds.
Re:SPAs Are Dead? by ivoecpereira on Wednesday April 07, 2021 @04:53PM (#26731108)
If doing that, why not go full-mode and store JWT in cookie with http-only flag?
Re:SPAs Are Dead? by shock-value on Wednesday April 07, 2021 @05:28PM (#26731609)
There are good uses for page content to know what's in the JWT (display username, show logged-in status, etc). Cookies also have stricter size limits. Additionally, cookies by themselves are uniquely vulnerable to CSRF, although I guess these days using SameSite property correctly mitigates that.
Re:SPAs Are Dead? by jakelazaroff on Wednesday April 07, 2021 @08:44PM (#26733664)
You can prevent CSRF attacks by simply requiring a custom HTTP header: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Re...
Re:SPAs Are Dead? by pier25 on Wednesday April 07, 2021 @07:34PM (#26733032)
True, although in the vast majority of cases JWTs are sent via HTTP headers (specially if you're making requests to multiple domains).