Connect
defaultValue()
Default value function, checking the req.body
and req.query for the CSRF token.
Source
function defaultValue(req) {
return (req.body && req.body._csrf)
|| (req.query && req.query._csrf)
|| (req.headers['x-csrf-token']);
}
Anti CSRF
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.
The default
valuefunction checksreq.bodygeneratedby the
bodyParser()middleware,req.querygeneratedby
query(), and the "X-CSRF-Token" header field.This middleware requires session support, thus should be added
somewhere below
session()andcookieParser().Options
valuea function accepting the request, returning the tokenSource