devxlogo

Spring Admin Expiring all Session of a Certain User

Spring Admin Expiring all Session of a Certain User

http     .formLogin().loginPage("/login").successForwardUrl("/").defaultSuccessUrl("/")     ...     .sessionManagement().maximumSessions(1).maxSessionsPreventsLogin(false)     .sessionRegistry(sessionRegistry())     ...@BeanSessionRegistry sessionRegistry() {    return new SessionRegistryImpl();}@Autowiredprivate SessionRegistry sessionRegistry;sessionRegistry.getAllPrincipals().stream().filter((principal)     - (principal instanceof User)).map((principal)     - (UserDetails) principal).filter((userdetails)     - userDetails.getUsername().equals(email))).forEachOrdered((userDetails)     - {               sessionRegistry.getAllSessions(userDetails, true).forEach((information)               -{                        information.expireNow();                   });       });

devx-admin

Share the Post: