Difference between #1 and #2 of
Simple RBAC

Revision #2 has been created by hasanavi on Apr 29, 2012, 10:16:22 PM with the memo:

« previous (#1) next (#5) »


Title unchanged

Simple RBAC

Category unchanged


Yii version unchanged

Tags unchanged

Simple RBAC, Role based access control, roles, Authentication, Role based menu

Content changed

If you are the one who needs simple Role based access control without the long RBAC process then this article is just for you. Lets jump to the point. On your user table make a column namesd 'roles' When you add users under roles you can assign them different roles like 'Admin' / 'user' / 'staff' etc etc. On your User Identity.php file write something like..

Now, make a Utils.php file under protected/components directory and implement a simple Role check function based on how many roles you have.



Here I just protect my AdminController.php from
unauthorised accessother roles than Admin. Basically from AdminController.php file accessRules() function it checks the users Roles written in Utils.php file. You can also use 1just one menu for all users based upon different roles. for example

<?php $this->widget('zii.widgets.CMenu',array(
array('label'=>'Users', 'url'=>array('/manageUser/admin'), 'visible'=>Utils::isAdmin()),
array('label'=>'Ideas', 'url'=>array('/manageIdea/admin'), 'visible'=>Utils::isAdmin()),
33 1
Viewed: 104 673 times
Version: 1.1
Category: Tutorials
Written by: hasanavi
Last updated by: Stageline
Created on: Apr 29, 2012
Last updated: 7 years ago
Update Article


View all history