You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Ed Young <ej...@summitbid.com> on 2009/12/05 00:14:35 UTC

Grails Shiro Role.addToPermissions("controller: view1, view2:1,2,x") does not work like User.addToPermissions("controller: view1, view2:1,2,x")

I posted this to the grails list, so my apologies if that constitutes a
cross post.

I'm pretty sure this is a bug...

I'm using grails 1.1.2 and Grails Shiro plugin 1.0.1.

In my Bootstrap.goovy I'm hardcoding several Roles and Users with
permissions, but I can't define the Role permission with the same
granularity as I can when I apply the permission to the User.

That is,
adminRoleDAC1Proj.addToPermissions("project:index,list,show:1,2") // doesn't
work

but

 userLoser2.addToPermissions("project:index,list,show:1,3")  // this works
just fine

What happens is the person assigned the role does not have access to the
domain objects corresponding to the permissions
"project:index,list,show:1,2" for example, but if I
apply the same permissions string to a User it works.

class BootStrap {
...

       // Administrator role for proj DAC1.
        def adminRoleDAC1Proj = new ShiroRole(name: "AdminDAC1")
//        adminRoleDAC1Proj.addToPermissions("project:index,list,show:1,2")
// doesn't work
//        adminRoleDAC1Proj.addToPermissions("project:index,list,show")
 // works
        adminRoleDAC1Proj.addToPermissions("project:*:1,2")  // doesn't work
        adminRoleDAC1Proj = thangValidator(adminRoleDAC1Proj)

       //  User loser who can see some report
        def userLoser2 = new ShiroUser(username: "loser2", passwordHash: new
Sha1Hash("password").toHex())
        userLoser2.addToRoles(userRole)
        userLoser2.addToPermissions("project:index,list,show:1,3")  // this
works just fine
        userLoser2 = thangValidator(userLoser2)

}

-- 
- Ed

Re: Grails Shiro Role.addToPermissions("controller: view1, view2:1,2,x") does not work like User.addToPermissions("controller: view1, view2:1,2,x")

Posted by Peter Ledbrook <pe...@cacoethes.co.uk>.
> I posted this to the grails list, so my apologies if that constitutes a
> cross post.
> I'm pretty sure this is a bug...
> I'm using grails 1.1.2 and Grails Shiro plugin 1.0.1.

I've replied now on the Grails user mailing list. Sorry, I did read it
and meant to come back to it. It's probably a bug in the generated
realm.

Peter