【发布时间】:2020-12-02 12:20:03
【问题描述】:
我正在使用 Spring Security 5.0.13,我想为登录页面激活 csrf 保护。我正在使用 xml 配置,我是从
<http>
...
<csrf disabled="true"/>
</http>
到
<bean id="csrfMatcher" class="org.springframework.security.web.util.matcher.AntPathRequestMatcher">
<constructor-arg name="pattern" value="/j_spring_security_check"/>
<constructor-arg name="httpMethod" value="POST"/>
</bean>
<csrf request-matcher-ref="csrfMatcher" />
不过,j_spring_security_logout 端点现在需要 POST 请求,而它过去接受的是 GET 请求。我知道有一个POST 请求注销按钮会更好,但我不能破坏这个功能,因为它在我控制之外的其他地方使用。
如何在不影响注销 url 动词的情况下为登录页面激活 csrf 保护?
【问题讨论】:
标签: java spring spring-security csrf