INI Based Permission Component

Yet another permission component was created this week but this time, it’s simplier and written in a text file. In one of our project, one of the follow-up requirement was to allow users of certain groups upgrade into a better status. The project was already in production and I was using ACL with Auth component to do my authentication. Unfortunately, this is one of ACLs weakness.
Changing a users group does not change the ARO parent (effectively making it useless/impossible to change groups). I tried fixing this home-brew style, but since there’s no setParent in 1.2’s db_acl, it’s far harder than it should be.That was reported back in 2007 and there was still no solution found in the net. It is also not an option for me to go through the above suggestion in fixing the problem so the the other solution is to find another one or create one. I chose the latter.

Why create a new one?The other solutions that I found still needs some configuration in the controllers. Since I already have a ton of files, I don’t want to go through all of them to add a line or two. I need ACLs way of doing it all in the background. Also, I am already using Auth component and I want to keep it.Why did I choose a text file over a database?My intention is to make the application faster since load time is really getting slower. Since the application isn’t that big, I only have less than 200 lines for the permissions, so a database is just overkill. Even if I use a database, I might cache it anyway so it saves me extra query.

The componentSo Permission Component was created. Below is the instruction on how to install it.

  1. Download this component and copy to your components folder.
  2. Create cake_dir/app/config/permissions.ini

The content for permissions.ini is as follows

[ControllerName]
actionName = group_id,group_id
 
[PluginName.ControllerName]
actionName = group_id,group_id

The ControllerName should be the controller name itself (in camel-case format).The actionName is also the action name itself (in camel-case format).The PluginName is the plugin name itself (in camel-case format).The group_id is the one written in your Auth component. Your Auth component should have a group_id value because this is what our Permission component will look for. It could be a number or set of characters.

Example:

; Group ID 1 = Admin
; Group ID 2 = Member
[Accounts]
index =
add = 1
edit = 1,2
delete = 1,2
 
[ShoppingCart.Orders]
index =
report = 1
Assigning no group id in an actionName will simply ignore it.

ReminderUse at your own risk. If you found a bug, please post them at the comment form.