设置requireCsrfProtectionMatcher后未找到Spring安全注销url

设置requireCsrfProtectionMatcher后未找到Spring安全注销url,spring,spring-security,csrf,Spring,Spring Security,Csrf,在我的Spring安全配置中实现了csrfProtectionMatcher之后,为了在面向UI的REST方法上使用CSRF令牌,我注意到通过 .and()// .logout()// .logoutUrl("/logout")// .deleteCookies("JSESSIONID")// 再也找不到了404 我发现我必须注册一个logoutRequestMatcher: .and()// .logout()// .logoutUrl("/logout")// .deleteCookies

在我的Spring安全配置中实现了csrfProtectionMatcher之后,为了在面向UI的REST方法上使用CSRF令牌,我注意到通过

.and()//
.logout()//
.logoutUrl("/logout")//
.deleteCookies("JSESSIONID")//
再也找不到了404

我发现我必须注册一个logoutRequestMatcher:

.and()//
.logout()//
.logoutUrl("/logout")//
.deleteCookies("JSESSIONID")//
.logoutRequestMatcher(request -> {
      RegexRequestMatcher logoutRequest = new RegexRequestMatcher("/logout", null);

      if (logoutRequest.matches(request)) {
          return true;
      }

      return false;
})//

有人能解释为什么吗

如果CSRF保护,则注销方法=Postahh,有意义:谢谢