Complete the code to import the CSRF middleware in Express.
const csrf = require('[1]');
The csurf package provides CSRF protection middleware for Express.
Complete the code to add CSRF protection middleware to the Express app.
app.use(csrf({ [1] }));Setting cookie: true tells csurf to store the CSRF token in a cookie.
Fix the error in the code to correctly send the CSRF token to the client in a template.
res.render('form', { csrfToken: req.[1]() });
The CSRF token is generated by calling the req.csrfToken() method.
Fill both blanks to correctly set up CSRF protection with cookie parser and session in Express.
app.use([1]()); app.use([2]());
To use CSRF protection with cookies and sessions, you first add cookie-parser middleware, then session middleware like express-session.
Fill all three blanks to create a dictionary of CSRF tokens for multiple forms in Express.
const tokens = {
login: req.[1](),
signup: req.[2](),
reset: req.[3]()
};The CSRF token is generated by calling req.csrfToken() each time you need a token for a form.