How to manually log out a user with spring security?

后端 未结 9 1304
情话喂你
情话喂你 2020-11-29 21:06

Probably the answer is simple: How can I manually logout the currently logged in user in spring security? Is it sufficient to call:

SecurityContextHolder.get         


        
9条回答
  •  情书的邮戳
    2020-11-29 21:24

    In Servlet 3.0 container Spring logout functionality is integrated with servlet and you just invoke logout() on your HttpServletRequest. Still need to write valid response content.

    According to documentation (Spring 3.2):

    The HttpServletRequest.logout() method can be used to log the current user out.

    Typically this means that the SecurityContextHolder will be cleared out, the HttpSession will be invalidated, any "Remember Me" authentication will be cleaned up, etc.

提交回复
热议问题