Assign ROLE dynamically to a controller action using grails ACL
I can grant permission for different roles in controller action as below:
class ThingController {
@Secured(['ROLE_ADMIN', 'ROLE_SALES', 'ROLE_OTHERS'])
create() {
// creation logic
}
}
that means, user with above roles can access the 'create' action. well,
that's fine. But here roles are defined as hard coded. But, if want to add
more roles or remove one of the roles from the 'create' action
dynamically, how can i do that?
I tried like
String roles='ROLE_ADMIN'
@Secured(["'"+roles.toString()+"'"])
But gets error:
Attribute 'value' should have type 'java.lang.String'; but found type
'java.lang.Object' in @grails.plugins.springsecurity.Secured @ line -1,
column -1.
Any help will be appreciated.
No comments:
Post a Comment