Role Based Access Manager (RBAM) is a Yii module that provides complete management of Authorisation Data (Authorisation Items, Authorisation Hierarchy, and Authorisation Assignments) for Yii’s Role Based Access Control system via a browser interface; it is intended for use in development and end-user administration environments.
RBAM has an intuitive “Web 2.0” interface to easily manage Authorisation Items (Roles, Tasks, and Operations), their hierarchy, and Authorisation Assignments. It presents all of an Authorisation Item’s information in one place providing a comprehensive overview and complete management of the item.
RBAM’s “Drill-down” and “Drill-up” features quickly show an item’s position in the Authorisation Hierarchy, what permissions it inherits (Drill down) and which Roles inherit its permissions (Drill up).
RBAM is built on top of Yii’s CAuthManager component and supports both of Yii’s built-in Authorisation Managers, CDbAuthManager and CPhpAuthManager, and authorisation managers extended from them.
RBAM supports I18N; it comes with German and Spanish translations (these are mine courtesy of Google - so poor at best).
Since V1.5 a Russian translation in included (thanks to Jangos)
If you have translation for RBAM and would like it included, please add to the RBAM thread in the forum; I'll add them in to the future releases.
| Status | Yii | Chrome | Firefox | MSIE | Opera | Safari | OS |
|---|---|---|---|---|---|---|---|
| Tested with | 1.1.5 | 8.0 | 3.68 | 8.0 | 10.63 | 5.0 | Windows 7 |
| Should work with | 1.x.x | All | 2.0+ | 6.0+ | 9.0+ | 3.0+ | All |
Extract the download archive onto the required folder. RBAM can be installed as a "top-level" module (in /protected/modules) or a nested module (in the modules directory of a parent module.
Edit your configuration file (if a "top-level" module)
‘modules’=>array( ‘rbam’=>array( // RBAM Configuration ), ),
(if a nested module)
‘parentModule’=>array( // Parent Module Configuration ‘modules’=>array( ‘rbam’=>array( // RBAM Configuration ), ), ),
Access RBAM in your browser at _http://your.domain/index.php?r=[parent module/]*rbam
You can download the demo (it's just the Yii "testdrive" app with RBAM and a user model). This comes with some Authorisation Data in place. The demo uses CPhpAuthManager; you can change the config to use CDbAuthManager (the config has the Yii demo SQLite db component) and import the PHP Authorisation data.
Before running the demo you will need to edit index.php to point to your Yii installation.
Total 20 comments
Hi,
There's this issue I'm still looking into that is described here. In the meantime, please be advised that the bizrule attached to Guest role will lead to incorrect behavior (=bug) if Authenticated is to inherit from Guest, which is natural to assume. Solution? Remove the bizrule from the Guest role so anyone, from RBAC perspective could assumed to be of this role, including authenticated users. No, this is only an permissions granting perspective. If you think about it it bears no implication regarding application flow in general.
If User table have id column's type is not int ( example : varchar) . Fix these line:
\rbam\views\authAssignments\assign.php:
jQuery("#AuthAssignment_userId").val('.$user->{$module->userIdAttribute}.');
=>
jQuery("#AuthAssignment_userId").val("'.$user->{$module->userIdAttribute}.'");
\rbam\components\behaviors\RbamDbAuthManagerBehavior.php
$condition = 'type='.CAuthItem::TYPE_ROLE." AND name NOT IN(SELECT itemName FROM {$owner->assignmentTable} WHERE userid=$uid)"; =>
$condition = 'type='.CAuthItem::TYPE_ROLE." AND name NOT IN(SELECT itemName FROM {$owner->assignmentTable} WHERE userid='$uid')";
I think your demo page is broken.
in DataValidator
If you want to put this module (or any other module) in another folder, configure like this:
Put rbam folder in protected/extensions/:
There's a bug that enables a person with the role 'authAssignmentsManagerRole' to assign somebody (even himself) the 'rbacManagerRole' role, and then scaling privileges. To avoid this, you've to modify the method 'getEUnassignedRoles' and put the following:
I import the SQL schema (\yii\framework\web\auth\schema-mysql.sql). then this is the config:
First, I could not go beyond the 'not initiliazed' screen. Second, I could, using this configs:
After logout and login again, i am receiving a 403 error page. I cant access rbam any way else.
I tryed to change the initialise to false, I tryed to create an user RBAC Manager, to log using it, but the 403 persists.
Now I am leaving this extension. Thanks anyway.
,
as the title says, the demo has an error. can you fix it so i cloud check if this extension could help me :D thx
You don't have to initialize it when you set the proper roles (the initialize message is only shown when you don't have access to the RBAM interface). For instance, my application uses:
The message you saw implies that it needs to be initialized, and is misleading. Maybe the author can change it?
An option to disable (role based) authentication to the RBAM module would be handy though. For example, I only enable the module in my development environment where I wouldn't require access checks to RBAM.
This is the second rbac extension I've tried to get working in my app, yii-rbac, and now your rbam.
RBAM comes up fine, but demands to be initialized. Why wouldn't it just use the data in the tables that is already available?? I've completed the Agile-yii book and have authmanager working, just not an easy way of viewing and managing roles, tasks and operations.
Please help out with a detailed data array that initialise can use, or let it just go into a mode where it can use what's there.
thanks,
The demo does not work or is it just for me?
rbam\views\authAssignments\assign.php
replace two
with
>
After integrating this extension in my application, it seems parts of the styling are missing. For example, the form on "rbam/authItems/create?type=2" has no styling applied to it. Any solutions?
Hi yeti just installed latest version of RBAM but I'm stuck on RBAM Not Initialised what should I do ?
I have a working example again! RBAM forum thread
doodle
This should be
I caught that typo but it still didn't work as expected. doodle
@Yeti thanks so much for your help, I agree with your approach and no I did not realize that roles where the same as authItems, that should definitely be in the guide!
So now I want only a super admin or the owner of the document to edit the document. I have done stuff like this in the past but I could never figure out the business rules.
According to the guide.
My model is called 'Webpage' and the field 'createdby' contains the id of the user who created this page. So this is my business rule.
in my accessRules
My user 'demo' has one role 'member', member role has two tasks 'ViewPageContent' and 'editOwnPage' the first task doesn't really do anything but the second contains a business rule. Setup this way the user 'demo' cannot edit any pages.
If I change my accessRules to this
Then user 'demo' can edit any page.
Thanks in advance for your help, I really find the RBAC part of Yii confusing. doodle
@doodle As you say, there is usually more than one way to things in Yii, and what you have will work just fine. Another (IMHO better) way is to declare access control in the controller's accessRules() method; this is the logical place and describes what is going on, and means the actions don't need to worry about authorisation - if they get called the user is authorised and they can just get on with what they need to do.
Taking your example this would become:
Note: the "roles" in accessRules refers to roles, tasks and operations (it's badly named in my opinion - should have been authItems to describe it better, but we have what we have)
The real benefit and beauty of RBAC comes by defining a hierarchy. Consider this: Have the roles "PageManager" and "PageEditor"; users are assigned appropriately Have the tasks "EditPage", "EditOwnPage" Have the operations "Create", "Delete" (The Create and Delete operations could equally well be tasks. I like have atomic actions as operations, others prefer direct inheritance by roles to be tasks; it's purely personal preference and makes no difference.)
The hierarchy is: PageManager inherits EditPage, Create, and Delete PageEditor inherits EditOwnPage and Create EditOwnPage has a business rule that checks that the page creator is the current user
(Defining the above roles, tasks, operations, hierarchy and assignments is what RBAM and other extensions - Rights and SRBAC - manage)
In the PagesController there are the "create", "update", and "delete" actions.
The access rules can now be: public function accessRules() { return array( array('allow', 'actions'=>array('create'), 'roles'=>array('Create'), // PageManagers and PageEditors will be allowed ), array('allow', 'actions'=>array('update'), 'roles'=>array('EditPage', 'EditOwnPage'), // PageManagers will be allowed to update all pages, PageEditors only their own ), array('allow', 'actions'=>array('delete'), 'roles'=>array('Delete'), // Only PageManagers will be authorised ), // other access rules array('deny', 'users'=>array('*'), ), ); }
Like all things Yii there are many ways to do things. I like the idea of creating a task and assigning it to a role.
I managed to protect an entire controller from being accessed by anyone not having a task within their role with the following code.
In this example the task is 'EditPageContent'
thanks
Leave a comment
Please login to leave your comment.