How to manually log out a user with spring security?
It’s hard for me to say for sure if your code is enough. However standard Spring-security’s implementation of logging out is different. If you took a look at SecurityContextLogoutHandler you would see they do: SecurityContextHolder.clearContext(); Moreover they optionally invalidate the HttpSession: if (invalidateHttpSession) { HttpSession session = request.getSession(false); if (session != null) { session.invalidate(); } … Read more