Difference between #8 and #13 of
How to setup RBAC with a php file

Changes

Title unchanged

How to setup RBAC with a php file

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

Authentication

Content changed

[...]
HOWEVER: since Yii rewrites the auth.php file into a form that's far more difficult to edit, it's a good idea to edit a **auth.txt** file, where you can format and comment properly, then copy it to auth.php when you're ready to try it. The first time Yii rewrites auth.php it will be apparent why you want to do this.

Declare some roles in our auth.txt file:

```php
// protected/
runtimedata/auth.txtphp

return array(
[...]
'type'=>CAuthItem::TYPE_ROLE,
'description'=>'Can only read a post',
'bizRule
s'=>'',
'data'=>''
),
[...]
'type'=>CAuthItem::TYPE_ROLE,
'description'=>'Can post a comment',
'bizRule
s'=>'',
'data'=>''
),
[...]
'reader','commentor'
),
'bizRule
s'=>'',
'data'=>''
)
[...]
```

## Ad
iditional/optional settings: ##

In your auth.php file you can use the following parameters:
[...]
[CAuthManager](http://www.yiiframework.com/doc/api/CAuthManager)<br />
[RBAC clarification](http://www.yiiframework.com/forum/index.php?/topic/2313-rbac-confusion)<br />
[another related rbac approach](http://yiiframework.ru/doc/cookbook/ru/access.rbac.file)<br />
 
[CPhpAuthManager - how it works, and when to use it](http://www.yiiframework.com/wiki/253/cphpauthmanager-how-it-works-and-when-to-use-it)<br />
>Disclaimer: The above code works for me. I do not guarantee that it will work in all situations. If you need more complex RBAC structure use the DB one. I've read all posts in the forum re: RBAC but none of them helped me so the above code has been discovered through trial & error. Use it on your own responsibility.
24 4
21 followers
Viewed: 114 210 times
Version: 1.1
Category: How-tos
Written by: bettor
Last updated by: Stageline
Created on: Feb 7, 2010
Last updated: 12 years ago
Update Article

Revisions

View all history