我正在為我正在處理的 Spring-MVC 專案添加 csrf 安全性。我正在使用 Spring security 5.2.15 并在此處遵循此答案以禁用特定 URL 的 csrf。
如何將此作為引數添加到我的 XML 組態檔中的csrfMatcher bean 中?
uj5u.com熱心網友回復:
我通過應用 bean 標記并利用靜態物件與$一起使用的類來參考它來解決這個問題。
<b:bean id="csrfMatcher" class="org.springframework.security.web.util.matcher.AndRequestMatcher">
<b:constructor-arg name="requestMatchers">
<b:list>
<b:bean class="org.springframework.security.web.csrf.CsrfFilter$DefaultRequiresCsrfMatcher" />
<b:bean class="org.springframework.security.web.util.matcher.NegatedRequestMatcher">
<b:constructor-arg>
<b:bean class="org.springframework.security.web.util.matcher.AntPathRequestMatcher"
c:pattern="login.html"/>
</b:constructor-arg>
</b:bean>
</b:list>
</b:constructor-arg>
</b:bean>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/508394.html