简体   繁体   English

在spring-security中更改csrf令牌

[英]change csrf token in spring-security

i am using csrf in spring security, like this 我在春季安全中使用csrf,像这样

<http auto-config="false" >
    ...
    <csrf />
    ...
</http>

and put in every jsp page like this 并像这样放入每个jsp页面

<meta name="_csrf" content="${_csrf.token}" />
<meta name="_csrf_header" content="${_csrf.headerName}" />

The problem is that, every time I refresh the page, i want change the token. 问题是,每次刷新页面时,我都想更改令牌。 but as long as the user is logged in, the token does not change. 但是只要用户登录,令牌就不会更改。

Spring default use per-session csrf, you could check here for its implementation. Spring默认使用每会话csrf,您可以在此处检查其实现。 Per change token, I recommend you implement your own . 对于每个更改令牌,建议您实施自己的。 And call its method to reset token when you need to. 并在需要时调用其方法以重置令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM