【发布时间】:2021-06-05 02:18:09
【问题描述】:
我想用控制器做一个注销服务。我尝试下一个代码:
@GetMapping("/logout")
public String getLogoutPage(HttpServletRequest request, HttpServletResponse response){
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null)
new SecurityContextLogoutHandler().logout(request, response, authentication);
return "redirect:/login";
}
我其实是在用邮递员做测试
下一个 url 请求身份验证(“/example”),但是当注销时我仍然可以使用相同的令牌转到此 url,这是不对的。
【问题讨论】:
-
你不能用Token注销,如果你想这样做你必须使这个token无效,例如保存它并比较请求中的token没有保存。
标签: java spring-boot oauth-2.0 jwt logout