Commit f837d210 authored by 杨伊博's avatar 杨伊博

add session Registy

parent ff7b3add
...@@ -26,6 +26,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -26,6 +26,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired @Autowired
private CustomUserService customUserService; private CustomUserService customUserService;
@Autowired
SessionRegistry sessionRegistry;
@Autowired @Autowired
protected void configure(AuthenticationManagerBuilder auth) throws Exception { protected void configure(AuthenticationManagerBuilder auth) throws Exception {
...@@ -48,10 +50,16 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -48,10 +50,16 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/**") .antMatchers("/**")
.permitAll() .permitAll()
.and() .and()
.sessionManagement().maximumSessions(1).maxSessionsPreventsLogin(true); .sessionManagement().maximumSessions(1).maxSessionsPreventsLogin(true).sessionRegistry(sessionRegistry);
http.httpBasic(); http.httpBasic();
} }
@Bean
public SessionRegistry getSessionRegistry(){
SessionRegistry sessionRegistry=new SessionRegistryImpl();
return sessionRegistry;
}
@Bean @Bean
public ServletListenerRegistrationBean httpSessionEventPublisher() { public ServletListenerRegistrationBean httpSessionEventPublisher() {
return new ServletListenerRegistrationBean(new HttpSessionEventPublisher()); return new ServletListenerRegistrationBean(new HttpSessionEventPublisher());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment