gpt4 book ai didi

java - 如何检查守卫是否在我的网站上抵御 CSRF 攻击?

转载 作者:行者123 更新时间:2023-11-29 08:53:32 25 4
gpt4 key购买 nike

<分区>

我有一个用 maven 构建的项目。我想确保跨站点请求伪造防护 ( this link ) 在每个页面上都有效。在 mvn clean install 之后,web.xml、pom.xml、属性文件和 csrfguard.jar 以正确的方式存在。

我如何检查守卫是否在工作,如果没有,我做错了什么?

谢谢

添加到 pom.xml:

<dependency>
<groupId>org.owasp</groupId>
<artifactId>csrfguard</artifactId>
</dependency>

添加到 web.xml:

<filter-name>CSRFGuard</filter-name>
<filter-class>org.owasp.csrf.CSRFGuard</filter-class>
<init-param>
<param-name>error-page</param-name>
<param-value>/page/error</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CSRFGuard</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>Owasp.CsrfGuard.Config</param-name>
<param-value>WEB-INF/Owasp.CsrfGuard.properties</param-value>
</context-param>
<context-param>
<param-name>Owasp.CsrfGuard.Config.Print</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.owasp.csrfguard.CsrfGuardServletContextListener</listener-class>
</listener>
<listener>
<listener-class>org.owasp.csrfguard.CsrfGuardHttpSessionListener</listener-class>
</listener>

-编辑

我检查了请求中的 token 。没有发送 token 。我错过了什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com