[英]Is it neccessary to renew CSRF token in JWT token for every request/response?
I'm developing a web application using symfony and JWT token for authentication. 我正在开发一个使用symfony和JWT令牌进行身份验证的Web应用程序。 For preventing XSS, JWT token is stored in cookies with HttpOnly attribute. 为了防止XSS,JWT令牌存储在具有HttpOnly属性的cookie中。 And for preventing CSRF, I used random csrf token. 为了防止CSRF,我使用了随机的CSRF令牌。 This token are stored in cookie and JWT token (encrypted). 该令牌存储在cookie和JWT令牌中(已加密)。 What I want to know is, is it necessary to renew csrf token in every response? 我想知道的是,是否需要在每个响应中都更新csrf令牌? Whats the best implementation? 什么是最佳实施?
Here's my settings in details: 这是我的详细设置:
Generally there is no need to renew CSRF token at every request. 通常,不需要在每次请求时都更新CSRF令牌。
BUT let's see what happens in your setting: 但是,让我们看看您的设置会发生什么:
So you must not put CSRF token in cookie because it is useless whether you renew it or not. 因此,您切勿将CSRF令牌放入cookie中,因为无论您是否续签它都没有用。
If you use "single page application" it would be better to pass JWT in Authorization
header. 如果使用“单页应用程序”,最好在Authorization
标头中传递JWT。 That makes CSRF-attack impossible (watch out anohter threats). 这使得CSRF攻击成为不可能(注意其他威胁)。
If you use "classical web application" it would be better to use "classical" CSRF tokens and "classical" session identifiers. 如果使用“经典Web应用程序”,则最好使用“经典” CSRF令牌和“经典”会话标识符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.