在注销控制器中,我尝试编写很多代码组合。现在我有这个:
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
new SecurityContextLogoutHandler().logout(request, response, auth);
}
SecurityContextHolder.getContext().setAuthentication(null);
auth.setAuthenticated(false);
但提供代码执行令牌后仍然有效。
我有什么错吗?最终如何撤销token?
您要找的班级是DefaultServices http://docs.spring.io/spring-security/oauth/apidocs/org/springframework/security/oauth2/provider/token/DefaultTokenServices.html, 方法revokeToken(String tokenValue)
.
Here https://github.com/raonicoelho/silverauth/blob/master/src/main/java/com/silverauth/controller/TokenController.java撤销令牌的控制器的示例,以及here https://github.com/raonicoelho/silverauth/blob/master/src/main/java/com/silverauth/config/OAuth2Config.javaoauth2 配置与DefaultServices
bean.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)