用于grails的Spring安全核心插件 - 无法从数据库访问RequestMap参数

时间:2015-01-16 03:33:19

标签: grails spring-security

我已经使用RequestMap安装了Grails Spring安全核心插件来从数据库中检索URL。我假设我设置了guide中提到的所有内容。当我开始申请时(http://localhost:8080/scadmin/index/),我很抱歉,您无权查看此页面。 admin用户已正确验证,但RequestMap不允许我访问该URL。我做错了什么?请帮忙。

Config.groovy中

grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.tx.sc.auth.User'
grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.tx.sc.auth.UserRole'
grails.plugin.springsecurity.authority.className = 'com.tx.sc.auth.Role'
grails.plugin.springsecurity.requestMap.className = 'com.tx.sc.auth.Requestmap'
grails.plugin.springsecurity.securityConfigType = 'Requestmap'

我的控制器 -

class AdminController {
    def index() {
        List<Portal> pList = portalService.listAllPortalInfo()
        render(view: "admin", model:[portalList:pList])
    }
}

设定角色

def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)

管理员用户

    def adminUser = new User(username: 'admin', password: '12345',email: 'admin@abc.com',enabled: true, accountLocked: false, accountExpired: false, passwordExpired: false).save(flush: true)

映射用户和角色 -

    if (!adminUser.authorities.contains(adminRole)) {
        UserRole.create(adminUser, adminRole, true)
    }

RequestMap -

 new Requestmap(url: '/scadmin/admin/index', configAttribute: 'ROLE_ADMIN').save(flush: true)

1 个答案:

答案 0 :(得分:0)

/scadmin/admin/index应该是/admin/index - 不要包含上下文。