Spring Boot Web MVC Allow one user at a time from anywhere, If he/she wants to login, then there will be forced login.
I have search a lot on internet, i found that i can do something like :
http.sessionManagement()
.invalidSessionUrl("/invalidSession")
.maximumSessions(1)
.maxSessionsPreventsLogin(true)
.sessionRegistry(sessionRegistry())
But this is not working, I am able to login from a different browser without any error.
I trying to solve this problem from last week but did not find any workable solutions.
Update
http.antMatchers("/", "/register/**", "/email/**","/captcha.png/**")
.permitAll()
.antMatchers("/login/**")
.permitAll()// Basically I'm allowing parameters for login so
// .antMatchers("/services/ownerTaxInformation/**")
.permitAll()
.antMatchers("/forgot/password/**", "/user/verify/**")
.permitAll()
.antMatchers("/user/resetPassword*")
.hasAuthority("CHANGE_PASSWORD_PRIVILEGE")
.anyRequest()
.authenticated()
.and()
.addFilterBefore(jCaptchaAuthenticationFilter(),UsernamePasswordAuthenticationFilter.class)
.formLogin()
.loginPage("/login")
.permitAll().and()
.csrf()
.disable()
.sessionManagement()
.invalidSessionUrl("/invalidSession")
.maximumSessions(1)
.maxSessionsPreventsLogin(true)
.sessionRegistry(sessionRegistry()).and()
.sessionFixation()
.none()
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/")
.invalidateHttpSession(false)
.deleteCookies("JSESSIONID")
.permitAll();