Difference between #5 and #6 of
Simple RBAC

Revision #6 has been created by François Gannaz on Apr 30, 2012, 3:54:13 PM with the memo:

Fixed 2 links
« previous (#5) next (#7) »


Title unchanged

Simple RBAC

Category unchanged


Yii version unchanged

Tags unchanged

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

Content changed


[CWebUser::checkAccess()] usually connects to the authorization system loaded in Yii.
Here we are replacing it with a simple system that just deals with roles instead of the hierarchical system defined by the derivatives of [CAuthManager]. See the official tutorial, [
Role-Based Access Control](http://www.yiiframework.com/doc/guide/1.1/en/topics.auth#role-based-access-control](Role-Based Access Control) for details.

## Checking permissions: usage
Here the "admin" action of the controller has restricted access: only those with roles "staff" or "devel" can access it.

As described in the API doc of [
CAccessRule](http://www.yiiframework.com/doc/api/1.1/CAccessRule#roles-detail](CAccessRule), the "roles" attribute will in fact call `Yii::app()->user->checkAccess()`.

### How to display a different menu according to roles

You can also use just one menu for all users based upon different roles. for example
33 1
Viewed: 95 236 times
Version: 1.1
Category: Tutorials
Written by: hasanavi
Last updated by: Stageline
Created on: Apr 29, 2012
Last updated: 5 years ago
Update Article


View all history