:
- cron 5 ( ), (.. , ) , .
- () Faye, UI ( Faye), .
You can use something like this to expire the token:
public void expireToken (HttpServletRequest request, HttpServletResponse response){
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null){
SecurityContextHolder.getContext().setAuthentication(null);
}
}
To get all current sessions, you can use the following:
public class UserController {
@Autowired
private SessionRegistry sessionRegistry;
public void listLoggedInUsers() {
final List<Object> allPrincipals = sessionRegistry.getAllPrincipals();
for(final Object principal : allPrincipals) {
if(principal instanceof SecurityUser) {
final SecurityUser user = (SecurityUser) principal;
expireToken();
}
}
}
}
Note. I personally avoid polling the backend from the interface, as it does not seem optimal.
source
share