java Spring安全性:/logout url被其他控制器捕获
您好,我有一个映射为@RequestMapping(value = "/{barUrlName}")
的控制器方法
我需要这种方式来保持良好的网址
然而,当我尝试使用/logout注销时(它应该由SpringSecurity管理),它会被这个映射捕获
有没有办法让Spring Security首先醒来? 我的另一个想法是在控制器中创建一个映射到/注销的其他方法,但我不知道如何在这个方法中手动注销
谢谢大家!
编辑:解决方案
正如Branislav Lazic和Serge Ballesta所提到的那样,我添加了一个更改logoutUrl的选项。在Java配置中,它给出:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
//CSRF enable
//.csrf().disable()
.authorizeRequests()
[...]
.and()
.formLogin()
.and()
.logout()
//with csrf you need to configure logoutRequestMatcher instead of logoutUrl if it is disable
.logoutRequestMatcher(new AntPathRequestMatcher("/app/logout"));
}
共 (0) 个答案