Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly are "tasks" in Yii's RBAC?

Tags:

yii

rbac

I'm diving into RBAC while designing new and rather big/complex site. I'm trying to figure out if to create a task or simply an operation with biz rule.

Now, I've read most if not all existing documentation. The current documentation says that "a task consists of operations". This wiki article says that the different terms are simply naming conventions and the only limitation that exists is structural one - roles must include tasks (or other roles); tasks should include operations (or other tasks) and operations is the atomic term that is not further composed by other entities. I've also read the relevant sections in the "Agile web dev..." and "Yii cookbook" books - both do not shed further light on this issue (at least as seen through my glasses).

Lets go to my example where I'll present the question. Actually, lets use an example similar to that demonstrated in most of the documentation resources mentioned above: Lets say I have a blog post and I want/need to have its author be able to "update own post". Now, why should this be a task as commonly demonstrated in the documentation resources and not an operation with a biz rule?

I think that the question above reveals the inclear definition of a "task" (in the RBAC context of course).

Please help me distill a better definition for an RBAC task.

EDIT: I was suggested the following definitions of the mentioned terms that help conceptualize them in a useful way. In short and in its simplest form: operations are the basic building blocks. They are the material developers work with and only them. Developers compose tasks of and on top of operations. Roles are composed of tasks, like a set of tasks. Roles and tasks are what the site administrators should play with - assign and revoke to users but not operations. That's a nice way to look and grasp those entities (roles, tasks and operations). Do you have another option to conceptualize differently? Any comments will be appreciated.

TIA! Boaz.

like image 575
Boaz Rymland Avatar asked Feb 20 '12 07:02

Boaz Rymland


2 Answers

I'd say the same as you did in your question edit. A task is simply a composition of operations a user can do that have something in common. So you have for example operations oList, oView, oCreate and oUpdate these are the operation developer assigns to controller actions for access control, where the first two are only read- and the second two have write access to data (that's what they have in common). So you now want to combine those to tasks tInspect and tManage which both hold 2 operations, the first one can list and view and the second one can create and update. Optionally you could make tInspect a sub-task of tManage so a user that has tManage can list, view, update and create but normally you just give his role both tasks.

like image 123
cebe Avatar answered Oct 06 '22 13:10

cebe


Regarding the classification of role -> task -> operation, they are essentially the same thing, as you can see in the code they are of class CAuthItem. We name them differently mainly from user point of view.

  • Operations are only used by developers and they represent the finest level of permission.

  • Tasks are built on top of operations by developers. They represent the basic building units to be used by RBAC administrators.

  • Roles are built on top of tasks by administrators and may be assigned to users or user groups.

The above is a recommendation, not requirement. In general, administrators can only see tasks and roles, while developers only care about operations and tasks.

Check this out : http://www.yiiframework.com/forum/index.php/topic/2313-rbac-confusion/page_p_16035#entry16035

like image 45
Anshuman Jasrotia Avatar answered Oct 06 '22 13:10

Anshuman Jasrotia