Hi All
I’m trying to setup RBAC. First I added the AuthManager component to main.php:
'authManager'=>array(
'class'=>'CDbAuthManager',
'connectionID'=>'db',
),
Next, I added a command to yiic (all this stuff comes from the book: Agile Webdevelopment with Yii) Anyway, I created the file RbacCommand.php in command/shell
<?php
class RbacCommand extends CConsoleCommand {
private $_authManager;
.....
public function run($args) {
......
//first we need to remove all operations, roles, child relationship and assignments
$this->_authManager->clearAll();
//create the lowest level operations for users
$this->_authManager->createOperation("createUser","create a new user");
$this->_authManager->createOperation("readUser","read user profile information");
$this->_authManager->createOperation("updateUser","update a users information");
$this->_authManager->createOperation("deleteUser","remove a user from a project");
//create the lowest level operations for projects
$this->_authManager->createOperation("createProject","create a new project");
$this->_authManager->createOperation("readProject","read project information");
$this->_authManager->createOperation("updateProject","update project information");
$this->_authManager->createOperation("deleteProject","delete a project");
//create the lowest level operations for issues
$this->_authManager->createOperation("createIssue","create a new issue");
$this->_authManager->createOperation("readIssue","read issue information");
$this->_authManager->createOperation("updateIssue","update issue information");
$this->_authManager->createOperation("deleteIssue","delete an issue from a project");
//create the reader role and add the appropriate permissions as children to this role
$role=$this->_authManager->createRole("reader");
$role->addChild("readUser");
$role->addChild("readProject");
$role->addChild("readIssue");
//create the member role, and add the appropriate permissions, as well as the reader role itself, as children
$role=$this->_authManager->createRole("member");
$role->addChild("reader");
$role->addChild("createIssue");
$role->addChild("updateIssue");
$role->addChild("deleteIssue");
//create the owner role, and add the appropriate permissions, as well as both the reader and member roles as children
$role=$this->_authManager->createRole("owner");
$role->addChild("reader");
$role->addChild("member");
$role->addChild("createUser");
$role->addChild("updateUser");
$role->addChild("deleteUser");
$role->addChild("createProject");
$role->addChild("updateProject");
$role->addChild("deleteProject");
...
}
}
When I run yiic:
./yiic shell config/main.php
or
./protected/yiic shell
(I guess there’s no difference between the two)
Anyway, it runs ok, and completes. But when I check the database tables AuthAssignment, AuthItem and AuthItemChild (because all my tables are prefixed with ‘tbl_’ I’ve also created these 3 tables with the prefix, but they’re also empty)
Any suggestions why there’s no DB action here (I know the DB stuff is setup correctly because it works for the web-application)?
thanks a lot
cheers
Luca