File tree Expand file tree Collapse file tree
springboot-springSecurity2/src/main/java/com/us/example/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
2626
2727 @ Autowired
2828 private CustomUserService customUserService ;
29+ @ Autowired
30+ SessionRegistry sessionRegistry ;
2931
3032 @ Autowired
3133 protected void configure (AuthenticationManagerBuilder auth ) throws Exception {
@@ -48,10 +50,16 @@ protected void configure(HttpSecurity http) throws Exception {
4850 .antMatchers ("/**" )
4951 .permitAll ()
5052 .and ()
51- .sessionManagement ().maximumSessions (1 ).maxSessionsPreventsLogin (true );
53+ .sessionManagement ().maximumSessions (1 ).maxSessionsPreventsLogin (true ). sessionRegistry ( sessionRegistry ) ;
5254 http .httpBasic ();
5355 }
5456
57+ @ Bean
58+ public SessionRegistry getSessionRegistry (){
59+ SessionRegistry sessionRegistry =new SessionRegistryImpl ();
60+ return sessionRegistry ;
61+ }
62+
5563 @ Bean
5664 public ServletListenerRegistrationBean httpSessionEventPublisher () {
5765 return new ServletListenerRegistrationBean (new HttpSessionEventPublisher ());
You can’t perform that action at this time.
0 commit comments