I'm making a Django Rest Framework application with a JWT authentication with tokens stored in HttpOnly cookies. Authentication is performed via reading the access
cookie. I'm using a dj-rest-auth
library for this purpose, but I'm a little confused of the security aspect of such method. Knowing that having authentication data stored in cookies can be used to perform CSRF attack, how can one protect their web against such attacks for a specific case I've described above? All cookies are set to be SameSite=Lex
.
Do I need to also send X-CSRFTOKEN
header obtained from the backend? That would mean that every request to the api will need to have that header. What should be the optimal setup having all those libraries?