You've probably seen how many websites allow a user to view and forcibly log out sessions for their account. We can easily use this forcible logout functionality to do the same. We have already provided UserSessionController, which obtains the active sessions for the currently logged in user. You can see the implementation as follows:
//src/main/java/com/packtpub/springsecurity/web/controllers/
UserSessionController.java
@Controller
public class UserSessionController {
private final SessionRegistry sessionRegistry;
@Autowired
public UserSessionController(SessionRegistry sessionRegistry) {
this.sessionRegistry = sessionRegistry;
}
@GetMapping("/user/sessions/")
public String sessions(Authentication authentication, ModelMap model) {
List<SessionInformation> sessions = sessionRegistry...