How to force logout using Grails / Spring Security Core?

How can I force logout for a registered user using Spring Security Core? I do not want to redirect to the exit page, etc., but you need to do this in the service.

+4
source share
2 answers

This is a different approach. I get exit handlers from the bean "logoutHandlers" and exit each of them:

def logoutHandlers def logout(request,response) { Authentication auth = SecurityContextHolder.context.authentication if (auth) { logoutHandlers.each { handler-> handler.logout(request,response,auth) } } } 
+5
source

I used the following code to achieve my goal:

 Authentication auth = SecurityContextHolder.context.authentication new SecurityContextLogoutHandler().logout(request, response, auth); new PersistentTokenBasedRememberMeServices().logout(request, response, auth); 
0
source

Source: https://habr.com/ru/post/1399751/


All Articles