INI Based Permission Component


Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/ini.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/ini.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/ini.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/promet/public_html/cakephp/wp-content/plugins/devformatter/geshi/geshi/ini.php) [function.fopen]: failed to open stream: Permission denied in /home/promet/public_html/cakephp/wp-content/plugins/devformatter/devgeshi.php on line 103

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 component

So 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

1

2
[ControllerName]
3
actionName = group_id,group_id
4
 
5
[PluginName.ControllerName]
6
actionName = group_id,group_id
7

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:

01

02
; Group ID 1 = Admin
03
; Group ID 2 = Member
04
[Accounts]
05
index =
06
add = 1
07
edit = 1,2
08
delete = 1,2
09
 
10
[ShoppingCart.Orders]
11
index =
12
report = 1
13

Assigning no group id in an actionName will simply ignore it.

Reminder

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

4 Responses to “INI Based Permission Component”

  1. Rolan Says:

    I’m not sure… but this might help:

    Auth and Acl – Automatically updating user Aros

  2. rachel Says:

    eek, I should have asked you before! Anyway, I am still happy with the new component since it’s easier to update. hehe.

  3. jojosiao Says:

    Hay naku,

    ini based Authentication — may problems yan at mas madali ma-hack.

  4. rachel Says:

    @jojo i was thinking of that but if you can move the permissions.ini to somewhere not accessible via web, is it still an issue?

Add Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>