CI-RBAC |
[eluser]xmonader[/eluser]
I wrote RBAC library < http://en.wikipedia.org/wiki/Rbac > based-on yii's CAuthManager Installation: 1- Download ci-rbac from https://bitbucket.org/xmonader/ci-rbac 2- It's included in a module (nothing functional except authitem_model, rbac_auth) named authman if (you are using HMVC) just copy and drop it in your modules folder else merge the (models/libraries) folders with your application (models/libraries) and *modify* loading the model in rbac_auth from Code: $this->CI->load->model("authman/authitem_model"); to Code: $this->CI->load->model("authitem_model"); 3- Import schema.sql to your database 4- That's all. Example: There's a hello controller provided with ci-rbac in the index method Code: $cp=$this->rbac_auth->createOperation("createPage", "create page"); *NOTE: the result of createOperation/createIssue/createRole are the id of the created item. (keep track of it as we will use it later) Now let's get to the roles Code: $guestRole=$this->rbac_auth->createRole("guest", "guest role"); Code: $memberRole=$this->rbac_auth->createRole("member", "member role"); Code: $ownerRole=$this->rbac_auth->createRole("owner", "owner role"); Code: $adminRole=$this->rbac_auth->createRole("admin", "admin role"); *Task is kinda higher-level representation of operations Code: $this->rbac_auth->assign("admin", 1); //admin as you can see user with id=1 is set to admin role, user 2 is set to member Code: $this->rbac_auth->assign("deleteIssue", 2); Checking access: Code: if ($this->rbac_auth->checkAccessForUser(1, "deletePage")){ Backends: Only DB-Backend for now
[eluser]maltzurra[/eluser]
Thanks! Loved Yii RBAC! Just as sidenote, it depends on MY_Model and MY_Controller
[eluser]xmonader[/eluser]
[quote author="maltzurra" date="1305640065"]Thanks! Loved Yii RBAC! Just as sidenote, it depends on MY_Model and MY_Controller [/quote] You are welcome. Yeah, I'll track it down as I developed it for some application and forgot to separate it from its dependencies
[eluser]xmonader[/eluser]
+I've removed the dependencies (MY_Model, MY_Controller)
[eluser]maltzurra[/eluser]
Thanks xmonader, I've modified some minor mistakes. I have not uploaded it to bitbucket to stick all in one place. Please take a look at - http://www.2shared.com/file/rK8RX1hC/rbac_modded.html
[eluser]xmonader[/eluser]
Thanks maltzurra for the fixes. I've merged it You can always push to your repo and I'll merge
[eluser]jellysandwich[/eluser]
I think I'm gonna be using this, but two things. 1) Using PHP 5.3.0, I get this error: Code: A PHP Error was encountered 2) Is there any support for bizrules? I see that create and assign functions set bizrules properly, but I can't find any functions that test/execute them. |
Welcome Guest, Not a member yet? Register Sign In |