I installed the Grails Spring Security Core plugin. As it works right now, a user is first taken to the default index.gsp page which lists the controllers. Once they click on a controller, they are prompted to log-in.
How can I modify Grails to show the log-in screen first, and re-direct to the default index.gsp page upon success?
Here is my Config.groovy:
// Added by the Spring Security Core plugin:
grails.plugins.springsecurity.userLookup.userDomainClassName = 'com.example.app.security.SecUser'
grails.plugins.springsecurity.userLookup.authorityJoinClassName = 'com.example.app.security.SecUserSecRole'
grails.plugins.springsecurity.authority.className = 'com.example.app.security.SecRole'
grails.plugins.springsecurity.securityConfigType = SecurityConfigType.InterceptUrlMap
grails.plugins.springsecurity.interceptUrlMap = [
'/attendance/*': ['IS_AUTHENTICATED_REMEMBERED'],
'/class/*': ['IS_AUTHENTICATED_REMEMBERED'],
'/county/*': ['IS_AUTHENTICATED_REMEMBERED'],
'/person/*': ['IS_AUTHENTICATED_REMEMBERED'],
'/state/*': ['IS_AUTHENTICATED_REMEMBERED'],
'/**': ['IS_AUTHENTICATED_ANONYMOUSLY']
]
UrlMappings.groovy:
static mappings = {
"/$controller/$action?/$id?"{ constraints { // apply constraints here
} }
"/"(view:"/index")
"500"(view:'/error')
"/login/$action?"(controller: "login")
"/logout/$action?"(controller: "logout")
}
add
to your interceptUrlMap.
Then, when a visitor goes to “/”, spring security will intercept and redirect to the login page, then redirect to “/” after the login.