I am testing NodeJS express
app that uses csurf
package along with express-session
package.
Problem
While testing, i have to make requests that should include csrf token
in them but because i don't really understand how csurf
middleware validates csrf tokens
in incoming requests, that is causing a lot of problems in testing the app.
Question
Can someone explain in simple terms, how csurf
middleware validates csrf tokens
when using csurf
middleware with express-session
package? How it validates token when it receives it in a request? Should tokens be sent in headers or in request body? Is new token created every time a new page is rendered or do we have once token per user session?
I also want to know how that the token validation process will change when using csurf
middleware with cookie-parser
package?