我正在开发一个 Spring Boot 项目和用于会话控制的 WebSecurityConfig。问题是,当会话过期时,我被重定向到/?sessionexpired我期望它应该重定向 o 的时候/?expiredsession。此外,当用户注销时,页面会重定向到/?sessionexpired而不是/?logout.
我的配置如下
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/thirdparty/**", "/webjars/**", "/sessionerror").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/")
.failureUrl("/?error")
.defaultSuccessUrl("/dashboard")
.permitAll()
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/?logout")
.logoutRequestMatcher(new AntPathRequestMatcher("/logout")) // override default of only allowing POST for logout so we can use a GET
.deleteCookies("remove")
.invalidateHttpSession(true)
.permitAll()
.and()
.sessionManagement()
.maximumSessions(1)
.expiredUrl("/?expiredsession")
.maxSessionsPreventsLogin(false)
.and()
.invalidSessionUrl("/?sessionexpired");
}
有人可以帮我解决这个问题吗?
白衣非少年
相关分类