Spring Security中每个请求的不同csrf令牌 [英] Different csrf token per request in Spring security

查看:275
本文介绍了Spring Security中每个请求的不同csrf令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Web项目的Spring Security xml文件中使用<csrf/>标记.并以以下形式发送csrf令牌:

I am using <csrf/> tag in my spring security xml file for a web project. And sending csrf token in a form:

<form action="" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>

但是在通过BurpSuite拦截请求时,我在每个请求上都获得了相同的csrf令牌,直到会话持续.

But on intercepting the request through BurpSuite i am getting same csrf token on every request till the session persist.

在Spring Security中,有什么办法可以使每个请求发送的CSrf令牌与每次会话发送的CSRF令牌不同.

Is there any way i could send different csrf token per request than per session in spring security.

我正在使用3.2.4弹簧安全罐.

I am using 3.2.4 spring security jars.

推荐答案

CSRF令牌的默认持续时间是会话持续时间. CSRF令牌存储在HTTP会话中,因此在每个会话的基础上生成.在CSRF上查看 Spring Security文档以获得更多详细信息.

Default duration of CSRF tokens is the session duration. The CSRF token is stored in the HTTP session and is therefore generated on a per-session basis. Check Spring Security documentation on CSRF for more details.

Spring Security可以扩展以满足个人需求,因此可以根据您的目的进行扩展.

Spring Security can be extended to suit individual needs, so it can be extended for your purpose.

但是,此扩展会影响可用性:

But, this extension influences usability:

  1. 在第二个标签中打开Web应用程序将导致一个或两个标签中的会话中断.
  2. 提交的表单上的后退"按钮可能会导致一些奇怪的错误.

这篇关于Spring Security中每个请求的不同csrf令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆