我已经设置了Spring Security核心插件。我想将它用于用户模块。设置完毕后,所有网址都无效,我的所有网页都被重定向到/login/auth
页面。我的默认页面是home/index
。另外,如何在登录页面上使用自定义设计?
以下是Config.groovy
grails.plugin.springsecurity.userLookup.userDomainClassName = 'nfp.NfpUser'
grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'nfp.NfpUserNfpRole'
grails.plugin.springsecurity.authority.className = 'nfp.NfpRole'
//grails.plugin.springsecurity.interceptUrlMap=[ '/': ['IS_AUTHENTICATED_ANONYMOUSLY'], '/**': ['IS_AUTHENTICATED_FULLY'] ]
//grails.plugin.springsecurity.rejectIfNoRule = true
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
'/': ['permitAll'],
'/index': ['permitAll'],
'/index.gsp': ['permitAll'],
'/assets/**': ['permitAll'],
'/**/js/**': ['permitAll'],
'/**/css/**': ['permitAll'],
'/**/images/**': ['permitAll'],
'/**/favicon.ico': ['permitAll']
]
答案 0 :(得分:1)
使用/
而不是使用/**
,而只限制您想要的几个模块:
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
'/user/list': ['ROLE_USER_MODULE']
'/**': ['permitAll'],
'/index': ['permitAll'],
'/index.gsp': ['permitAll'],
'/assets/**': ['permitAll'],
'/**/js/**': ['permitAll'],
'/**/css/**': ['permitAll'],
'/**/images/**': ['permitAll'],
'/**/favicon.ico': ['permitAll']
]
现在,如果您使用grails s2-quickstart nfp NfpUser NfpRole
命令设置插件,则Grails应用目录必须具有grails-app/views/login/auth.gsp
GSP。您可以根据您的外观自定义该GSP。
如果您没有找到该GSP,请从plugins/spring-security-core-<version>/grails-app/views/login/auth.gsp
复制该GSP并对其进行自定义。