/ / Jak wymusić programowe wylogowanie przy użyciu Grails / Spring Security Core? - Graale, wiosenne bezpieczeństwo

Jak wymusić automatyczne wylogowanie za pomocą Grails / Spring Security Core? - grails, sprężyna bezpieczeństwa

Jak mogę wymusić programowe wylogowanie zalogowanego użytkownika za pomocą Spring Security Core? Nie chcę przekierowywać na stronę wylogowania itp., Ale muszę to zrobić w usłudze.

Odpowiedzi:

5 dla odpowiedzi № 1

To jest inne podejście. Otrzymuję moduły obsługi wylogowania z komponentu bean „logoutHandlers” i loguję się w każdym z nich:

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

}

0 dla odpowiedzi nr 2

Użyłem następującego kodu, aby osiągnąć cel:

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