使用JSON Web令牌保护URL的正确方法

时间:2015-09-18 22:56:28

标签: node.js security cookies express jwt

说我有以下非api路线:

app.get('/userprofile', isAuthenticated(), function(request, response) {
    response.render('pages/userprofile');
});

使用JWT保护该路线的正确方法是什么?由于req来自浏览器,而不是客户端代码,因此不会有“Authorization:Bearer TOKEN”标头。但令牌将在req.cookies中。

据我所知,从cookie中读取令牌可以将网站打开到CSRF。我不想依赖服务器端会话,因为这违背了使用JWT的目的。在这种情况下使用expressjs csurf中间件也没有意义。

0 个答案:

没有答案