Spring Security authentication with Groovy Grails logout scenario
In this recipe, let's look at the logout implementation with Spring Security in the Grails application.
Getting ready
When we install the Spring Security plugin with Grails, the Login Controller
and Logout Controller
class will be created automatically. Login Controller
will handle the authentication. The Logout Controller
will handle the logout process, it will redirect the user to the common page.
How to do it…
The following steps are taken to implement the logout action in the Groovy on Grails application:
In the
index.jsp
file we add the following:<g:link controller='logout' action=''>Spring Logout</g:link>
The
Logout Controller
class to redirect the request toj_spring_security
:import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils class LogoutController { /** * Index action. Redirects to the Spring security logout uri. */ def index = { // TODO put any pre-logout code here ...