By default this middleware generates a token named "_csrf"
which should be added to requests which mutate
state, within a hidden form field, query-string etc. This
token is validated against the visitor's req.session._csrf
property which is re-generated per request.
The default value function checks req.body generated
by the bodyParser() middleware, req.query generated
by query(), and the "X-CSRF-Token" header field.
This middleware requires session support, thus should be added
somewhere belowsession() and cookieParser().
CRSF protection middleware.
By default this middleware generates a token named "_csrf" which should be added to requests which mutate state, within a hidden form field, query-string etc. This token is validated against the visitor's
req.session._csrfproperty which is re-generated per request.The default
valuefunction checksreq.bodygenerated by thebodyParser()middleware,req.querygenerated byquery(), and the "X-CSRF-Token" header field.This middleware requires session support, thus should be added somewhere below
session()andcookieParser().Examples
Options
valuea function accepting the request, returning the token