Quote
1. Create some mechanism to set up RBAC hierarchy (e.g. controller action as mentioned above)
2. Call this action once: The hierarchy will be saved to the data file
3. Whenever you add or revoke users to roles, this will also be written to the data file.
On every request the data file is read automatically by CPhpAuthManager. You should never touch that file manually!
It's not working this way...
I had put up all the auth.php code in an action of site controller. The auth.php is empty now. When I exec the action in browser it gives error like this while trying to load authorization data from auth.php
Quote
D:\xampp\htdocs\yii-1.0.9.r1396\framework\web\auth\CPhpAuthManager.php(449)
. Now this means I have to create the hierarchy in auth.php but when I do that... it doesn't create the object and I get the method call error on non-object error.
So I gave a thought about it and deleted the auth.php and called the action again. Guess what... IT WORKED!!!
Yii has created a new auth.php and the roles have been created in it. Now I know how the roles look like.
return array (
'sales' =>
array (
'type' => 2,
'description' => '',
'bizRule' => NULL,
'data' => NULL,
),
'recruitment' =>
array (
'type' => 2,
'description' => '',
'bizRule' => NULL,
'data' => NULL,
),
'screening' =>
array (
'type' => 2,
'description' => '',
'bizRule' => NULL,
'data' => NULL,
),
'admin' =>
array (
'type' => 2,
'description' => '',
'bizRule' => NULL,
'data' => NULL,
),
'authenticated' =>
array (
'type' => 2,
'description' => 'authenticated user',
'bizRule' => 'return !Yii::app()->user->isGuest;',
'data' => NULL,
),
'guest' =>
array (
'type' => 2,
'description' => 'guest user',
'bizRule' => 'return Yii::app()->user->isGuest;',
'data' => NULL,
),
);
Now I don't have to call the action anymore for minor changes... I can change the roles directly in this array.
Thanks Mike again, you last 3 points helped a lot. I think the documentation needs to provide a bit more detail on this thing as most people are asking the same question. Will catch you some time later
Hope this whole discussion will help someone get their rbac started right away without hassle.
Good Luck and regards,