【发布时间】:2021-11-25 01:31:45
【问题描述】:
我正在使用标准的 express CSRF 模块。它似乎工作正常,只是在注销并再次登录后,仍然可以使用上一个会话中生成的 CSRF 令牌。我认为使会话无效就足够了 - 请参见此处的代码示例,但这不起作用:
const csrf = require("csurf");
const csrfProtection = csrf({ cookie: true });
//CSRF protected route
app.post("/editUser",csrfProtection,async function (req, res, next) {
//Do stuff
});
//Logout route
app.get("/logout", function (req, res) {
req.session.destroy();
});
我需要做些什么来确保 CSRF 令牌在用户注销时失效?
【问题讨论】: