You can configure the 'user' application component in app config (like you do with other app component such as 'db', 'log').
The guide already shows the example code to create new roles and assignment. It is your responsibility to develop a GUI to call these code. We do plan to add a GUI in future releases (1.1 or 1.2).
1. You can configure the 'user' application component in app config (like you do with other app component such as 'db', 'log').
The guide already shows the example code to create new roles and assignment. It is your responsibility to develop a GUI to call these code. We do plan to add a GUI in future releases (1.1 or 1.2).
Yes, but how/where to hook my code into? By using main.php's 'preload' ?
By the way, great job you’re doing here, developing and helping out the community. My utmost respect
PS: I hope I'll understand yii's internals soon enough to be able to write some patches.
2. Yes, but how/where to hook my code into? By using main.php's 'preload' ?
I have tried to figure out that myself without sucess, so i guess the question is of more general interest. Were is the best place to put the code?
I't would be nice with a simple demo application that shows the basic principles i a little bit more complicated authentication sceme than the on en i e the blog demo. I't might be interesting to do a blog v2 with more advanced authentication.
I also share OriginalCopys respect for qiang, great work!
I kinda done something, at least now there's the flag is_admin pulled from the db into the app()->user at authentication time via CUserIdentity. I don't know if this is "the right way" in Yii terms, anyway the expression still does not evaluate. So here's the code:
class PostController extends CController
{
const PAGE_SIZE=10;
/**
* @var string specifies the default action to be 'list'.
*/
public $defaultAction='list';
/**
* @var CActiveRecord the currently loaded data model instance.
*/
private $_post;
public function init() {
throw new Exception(print_r('is admin:'.Yii::app()->user->is_admin,TRUE));
}
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'list' and 'show' actions
'actions'=>array('list','show'),
'users'=>array('*')
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete','create','update','remove'),
'expression' => array('!$user->isGuest && $user->is_admin')
),
array('deny', // deny all users
'users'=>array('*')
),
);
}
//....
However 'expression' is either not evaluated, nor it works as expected (I get the "Unauthorized" error page). Yet init() shows correctly "is admin: 1", so at least I managed to pull the info from the db, by using setState():
It should be a string. There's a bug in 1.0.3 which has been fixed in SVN.
Great. Could you tell me which revision that is? And please, please write log messages when commiting, there are many eye balls looking what you’re doing
It should be a string. There's a bug in 1.0.3 which has been fixed in SVN.
Great. Could you tell me which revision that is? And please, please write log messages when commiting, there are many eye balls looking what you’re doing
2. Yes, but how/where to hook my code into? By using main.php's 'preload' ?
hey mate… you need to run it just once… create an action in any controller with RBAC settings and in the end type $auth->save(), run it and then delete your action from the controller - RBAC settings should be saved once for all.