在我的Spring安全配置中实现csrfProtectionMatcher后,为了在面向REST方法的UI上使用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;
})//
任何人都可以解释原因吗? :)