我创建了OAuth 2.0服务器和一些客户端,但是我不怎么用SSO进行注销。注销后单击“登录”时,不需要更多的用户名和密码。我要“真的”登录。据说是一个棘手的问题
https://spring.io/guides/tutorials/spring-security-and-angular-js/
所以任何人都可以给我一些解决办法。
答案 0 :(得分:0)
将以下代码用于注销功能
@Controller
public class RevokeTokenController {
@Autowired
private TokenStore tokenStore;
@RequestMapping(value = "/revoke-token", method = RequestMethod.GET)
public @ResponseBody ResponseEntity<HttpStatus> logout(HttpServletRequest request) {
String authHeader = request.getHeader("Authorization");
if (authHeader != null) {
try {
String tokenValue = authHeader.replace("Bearer", "").trim();
OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
tokenStore.removeAccessToken(accessToken);
} catch (Exception e) {
return new ResponseEntity<HttpStatus>(HttpStatus.NOT_FOUND);
}
}
return new ResponseEntity<HttpStatus>(HttpStatus.OK);
}
}