我安装了 Grails Spring Security Core 插件。由于它现在工作,用户首先被带到列出控制器的默认 index.gsp 页面。一旦他们单击控制器,就会提示他们登录。
如何修改 Grails 以首先显示登录屏幕,并在成功后重定向到默认的 index.gsp 页面?
这是我的 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")
}