S
S
smichalev2021-09-02 09:36:21
HTTP Cookies
smichalev, 2021-09-02 09:36:21

How to implement CSRF protection in a SPA application?

Hello.
On the SPA front, in the Vue.js + Vuex + Websocket bundle
, JWT access/refresh tokens are selected as sessions. Tokens are stored in cookies with the http only and secure flag.
My version, which currently works, but I have doubts :)

We generate a csrf token for each request from the client to api, write the token as a key in memcached, and csrf as a value. After that, via websocket we send our token to all socket.id of the user. Those, in turn, set a new token in Vuex and sign every API request with it. On the api side, we check csrf and if something is wrong, we give an error.

How is it possible to protect the client from csrf and xss attacks in the SPA application to the maximum? And does my option have the right to life? Have I learned everything? Thank you very much for your reply.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question