In logout controller I tryed to write a lot of combination of code. Now I have this:
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
new SecurityContextLogoutHandler().logout(request, response, auth);
}
SecurityContextHolder.getContext().setAuthentication(null);
auth.setAuthenticated(false);
But after provided code execution token still valid.
What do I wrong? How to revoke token eventually?
The class you're looking for is
DefaultServices
, method revokeToken(String tokenValue)
.
Here an exemple of a controller that revokes token, and here the oauth2 configuration with the DefaultServices
bean.