【发布时间】:2020-05-25 05:50:25
【问题描述】:
我有一个包含 Spring 会话管理的 Spring Boot 应用程序。但是,我注意到当我关闭一个选项卡并尝试返回该站点时,我会收到错误提示。此外,当我关闭浏览器时,它会让我再次登录,我将在我的 JDBC 中看到两个具有相同主体 ID 的会话。因此,如果我在安全配置中弄乱了一些代码,或者这是典型的行为,我会感到困惑。另外,我也放松一下,如果达到用户超时,我需要找到一种方法来立即返回登录页面。目前,如果达到用户超时,则没有任何指示。我是 Spring Boot 会话管理的新手,我已经在线阅读了一些文档,但我阅读的一些文档令人困惑。如有任何帮助,将不胜感激。
安全配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().fullyAuthenticated()
.and()
.formLogin()
.successHandler(new CustomAuthenticationSuccessHandler()) // On authentication success custom handler
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/login");
http.sessionManagement().maximumSessions(50).maxSessionsPreventsLogin(true);
}
应用程序属性:
server.servlet.session.timeout=10m
【问题讨论】:
标签: java spring spring-boot