Grails Shiro Plugin: Confirming My Understanding

I am a little vague about how to get started using the siro plugin after reading a few docs. I decided against Nimble since it comes with several tables and UI plugins.

I am setting up the siro plugin with wildcard realm, with my own tables. I can use permission based access control (more precisely, role based access control) as it scales well. Now the steps are for him.

  • assign permission string to theme and store it in db
  • check permission via isPermitted, hasPermission (or corresponding tags in GSP).

Now,
1. when to use the access control filter?
2.Is there a closure injected into the controller where I can define permission for actions in it? I read somewhere about statically closing an accessControl on each controller, but it doesn't seem to be documented.
3. How to create a typical access control scenario, once the creator (something, post, etc.) can delete it? One possibility is to create and store a permission string based on user ID. check permission to get object (message), get user id and compare to subject .. seems tricky .. any simple implementation?

Many thanks. Woman.

+2


a source to share


1 answer


1, when to use the access control security filter?

and. Use accessControl {true} if you want to restrict access to controller actions for authenticated users.

C. Use accessControl () if you want to restrict access to controller actions regardless of the content of the parameter based on the "$ {control_name}: $ {actionName}" permissions.



C. If you want to restrict actions based on the content of a parameter, eg. delete only the domain object for which you have delete permission "$ {name}: $ {id}: delete", you need to explicitly check isPermited in the controller.

3 How to create a typical access control scenario as soon as the Creator?

I would add the required permissions (s) to the user when the post is created eg. "post: $ {postId}: *" Thus, permissions are owned by users and / or roles, not arbitrary domain objects as provided for in the Shiro mode of operation. Unlike file system permissions, which are owned by files and directories, not users.

+1


a source







All Articles