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();                   });       });
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist