【发布时间】:2017-08-05 11:07:25
【问题描述】:
我正在使用 Spring Boot 和 Thymeleaf。我在src/main/resources/templates/error/404.html 中定义了一个自定义的 404 模板页面
当用户登录时,这可以正常工作。
但是,当他们注销时,他们不会得到任何类型的 404 页面,他们只会被重定向回 /login。
我认为我的安全配置需要更改,但不确定是什么。
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/","/register*","/resetPassword","/forgotPassword","/login","/404").permitAll()
.antMatchers("/admin/**").hasAuthority("ADMIN").anyRequest()
.authenticated().and().formLogin().loginPage("/login").failureUrl("/login?error")
.defaultSuccessUrl("/dashboard").successHandler(successHandler)
.usernameParameter("email").passwordParameter("password")
.and().logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/login?logout").and()
.exceptionHandling().accessDeniedPage("/access-denied");
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/error**","/resources/**", "/static/**", "/css/**", "/js/**", "/img/**");
}
【问题讨论】:
标签: java spring spring-boot