ACL Management Plugin

By Jeff Loiselle aka "phishy"
A simple, easy, AJAXY, solution for managing your access control lists.
Introduction

It has been done before. I believe both Mariano Iglesias (mariano_iglesias) and Andy Dawson (ad7six) have both created ACL plugins. But unfortunately, at the time of this writing, neither of them worked for me. So I decided to create an AJAX ACL plugin. I needed one for my current project, plus I wanted to contribute something else to CakePHP outside of the crappy Oracle DBO that I wrote a year ago; and writing a fancy new plugin is way more fun that writing data import scripts and reports for my boss.

Before I waste too much of your time, you're welcome to check out a demo here:
http://dev.newnewmedia.com/cakephp/admin/acl

If you're still with me, then I can explain how you can get this puppy working for yourself.

Requirements:

Instructions for Installation

Note: At the time of this writing, CakePHP has no way of bundling images/css/js within the plugin. So if you want this thing to look pretty, you're going to have to do a little extra work.

  1. Download Prototype, drop the file directly into /app/webroot/js
  2. Download Tango Icon Library, name the folder 'tango', and put it in /app/webroot/img
  3. Checkout the ACL plugin source from svn and put the 'acl' folder in /app/plugins
  4. edit your core.php and turn on admin routing
  5. Browse to the address /admin/acl


That's it! The ACL management plugin should be installed. Usage instructions are built into the plugin, so I do not have to go on at length about it here.

If you have any questions feel free to leave comments here in the Bakery.

Comments 563

CakePHP team comments Author comments

Question

1 AclController could not be found

Strange...

The first page comes ok, but I've got a "Missing controller" error by clicking on anything (Manage Aros, Manage Acos or Manage Permissions).

Error details: "You are seeing this error because controller AclController could not be found."

Could you help with this?

Thank you
posted Mon, Nov 12th 2007, 22:48 by helio ricardo

Comment

2 Written for CakePHP 1.2

I failed to mention that this was written for CakePHP 1.2. Is that the version you are using?
posted Wed, Nov 14th 2007, 06:20 by Jeff Loiselle

Comment

3 AclController could not be found

I failed to mention that this was written for CakePHP 1.2. Is that the version you are using?

Im getting the same error using the pre-beta version of 1.2.
posted Wed, Nov 14th 2007, 07:44 by Jose M. Navas

Comment

4 Fix the menu links

I had to fix the links as well. Here's what I did:

in ../acl/views/elements/acl_menu.ctp
<div class="acl_menu">
<?php print $html->image('/tango/32x32/places/folder.png', array('align' => 'absmiddle')) ?><?php print $html->link('Acl Menu', array('controller'=>'acl','action'=>'admin_index')); ?>
<?php 
print $html->image('/tango/32x32/apps/system-users.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Aros', array('controller'=>'acl','action'=>'admin_aros')); ?>
<?php 
print $html->image('/tango/32x32/apps/preferences-system-windows.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Acos', array('controller'=>'acl','action'=>'admin_acos')); ?>
<?php 
print $html->image('/tango/32x32/emblems/emblem-readonly.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Permissions', array('controller'=>'acl','action'=>'admin_permissions')); ?>
</div>


And for the index page, ../acl/views/acl/admin_index.ctp
<ul class="acl">
<li><?php print $html->image('/tango/32x32/apps/system-users.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Aros', array('controller'=>'acl','action'=>'admin_aros')); ?></li>
<li><?php print $html->image('/tango/32x32/apps/preferences-system-windows.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Acos', array('controller'=>'acl','action'=>'admin_acos')); ?></li>
<li><?php print $html->image('/tango/32x32/emblems/emblem-readonly.png', array('align' => 'absmiddle')) ?><?php print $html->link('Manage Permissions', array('controller'=>'acl','action'=>'admin_permissions')); ?></li>
</ul>


And by the way Jeff, this is a really nice plugin and I am sure it will help me in my struggling with the auth/acl mess I've run into!
posted Thu, Nov 15th 2007, 12:04 by Daniel Jansson

Comment

5 Database Structure

Hi, I'm a newbie to Cake and am not sure how the database is supposed to be structured. Is there a link to the SQL for the table? Much help is appreciated.
posted Thu, Nov 15th 2007, 13:38 by Wendy

Comment

6 use the console to initialize the tables

Hi, I'm a newbie to Cake and am not sure how the database is supposed to be structured. Is there a link to the SQL for the table? Much help is appreciated.

You'll probably want to open up a shell, cd into the cake/console directory, and run this..

./cake acl initdb
posted Fri, Nov 16th 2007, 09:43 by Jeff Loiselle

Comment

7 Problems installing

Hello

i did all this:

1. Download Prototype, drop the file directly into /app/webroot/js
2. Download Tango Icon Library, name the folder 'tango', and put it in /app/webroot/img
3. Checkout the ACL plugin source from svn and put the 'acl' folder in /app/plugins
4. Browse to the address /admin/acl

http://www.dev.localhost/admin/acl

"You are seeing this error because controller AdminController could not be found.

Notice: If you want to customize this error message, create app/views/errors/missing_controller.thtml.

Fatal: Create the class below in file : app/controllers/admin_controller.php

<?php
class AdminController extends AppController {
var $name = 'Admin';
}
?>"


What should I do?
posted Tue, Nov 20th 2007, 10:43 by Jonas Hartmann

Comment

8 turn on admin routing

sorry, i failed to mention in my tutorial that you need to turn on admin routing in your core.php config file.
posted Tue, Nov 20th 2007, 11:31 by Jeff Loiselle

Comment

9 json requests not returned

Hi,


I am unable to get this plugin going. The issue is that the json requests are not returned. Initially upon installing I get this error

Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in D:Apache2.2.4vhosts..apppluginsaclcontrollersacl_aros_controller.php on line 36


removing the & in the foreach loop, still does not mena that requests are returned.

Warning (2): Missing argument 1 for children() [COREhtmlpluginsaclcontrollersacl_aros_controller.php, line 31]


I have made the changes above with the navigation and had a general fiddle around.


php4.4.7 cake1.2 pre beta

where am I going wrong??
posted Tue, Nov 20th 2007, 15:50 by Sam Sherlock

Comment

10 php5

i failed to mention i wrote this for php5. i'll rework it for php4 soon. stay tuned.
posted Mon, Nov 26th 2007, 06:01 by Jeff Loiselle

Comment

11 Downloading plugin

The demo looks great.
Now for the silly newbie question. How do I download the plugin code from svn://newnewmedia.com/cakephp/plugins/acl ?
I haven’t come across ‘svn’ before.
posted Sat, Dec 1st 2007, 11:11 by Lance

Comment

12 SVN

The demo looks great.
Now for the silly newbie question. How do I download the plugin code from svn://newnewmedia.com/cakephp/plugins/acl ?
I haven’t come across ‘svn’ before.


http://tortoisesvn.tigris.org/

a pleasure to use, simple also
posted Sat, Dec 1st 2007, 12:13 by Sam Sherlock

Bug

13 Showstopper Bug with the ACL Management Plugin in newer revisions

After searching for the problem for 8 hours I've found the bug that causes the ACL Management Plugin to malfunction in more recent revisions ( >= 606x).

Due to the use of a deprecated function (loadModel()) the plugins JSON model isn't loaded anymore. To solve the issue you have to replace the function

loadModel('JSON');

in each of the plugins controllers with

App::import(
$type = 'Model',
$name = 'JSON',
$parent = true,
$search = array("/your/path/to/the/plugins/JSON/dir","/Add/optional/paths/at/will"),
$file = 'JSON.php',
$return = false
);

Please help by hunting down bugs in other usefull plugins. Thanks for the ACL Manager, Jeff.
posted Sun, Dec 2nd 2007, 22:49 by Phillip

Question

14 not working for me

I have followed these instructions exactly. I can get to /admin/acl, but once I click on anything else, I am just shown this:

Missing controller

You are seeing this error because controller AclController could not be found.

Notice: If you want to customize this error message, create appviewserrorsmissing_controller.ctp

Fatal: Create the class below in file: appcontrollersacl_controller.php

<?php
class AclController extends AppController {
var $name = 'Acl';
}
?>

What am I doing wrong?
posted Sun, Dec 9th 2007, 16:45 by Luke Visinoni

Comment

15 cake1 2 0 5875 pre beta bug for cake acl initdb

In new released version cake_1.2.0.5875-pre-beta ,

 cake acl initdb 

gives following error:

..consoleconfig not found


Can any one help me sort out this bug ??

Thanks in advance.
posted Fri, Dec 14th 2007, 01:02 by s a khan

Question

16 cake1 2 0 5875 pre beta bug for cake acl initdb

In new released version cake_1.2.0.5875-pre-beta ,


 cake acl initdb 

gives following error:

 ...cake\console\config  not found 

Can any one help me sort out this bug ??

Thanks in advance.
posted Fri, Dec 14th 2007, 01:10 by s a khan

Question

17 SVN problems

hi jeff.
I'm having problem opening the ur svn url. FYI i'm using kdesvn.
posted Tue, Jan 8th 2008, 20:28 by eavay

Comment

18 can be a bug

In new released version cake_1.2.0.5875-pre-beta ,


 cake acl initdb 

gives following error:

 ...cake\console\config  not found 

Can any one help me sort out this bug ??

Thanks in advance.


yes i can confirm this as well. ANYONE PLS?!
posted Tue, Jan 29th 2008, 07:18 by Rahul

Comment

19 cake acl initdb

apparently the command behaves differently when run from ROOTcakeconsole AND ROOTapp

to people facing problems. run this cmd from ROOTapp. it will issue a warning that the its deprecated and give another cmd: cake schema run create DbAcl

this will work. (ps: ur database config file should be workable)
posted Tue, Jan 29th 2008, 08:14 by Rahul

Comment

20 fixed but works

I got PHP 5.2, CakePHP 1.2 beta
i had to fix it adding the $name var to the controllers

var $name = 'AclAros';
var $name = 'AclAcos';
var $name = 'Acl';
var $name = 'AclPermissions';

Now it works!
posted Wed, Feb 20th 2008, 12:18 by Ariel Patino

Comment

21 Plugin not working correctly.

My environment:
PHP 5
CakePHP 1.2.0.6811 - Beta
Plugin
Prototype 1.5.1.1
Tango Icon Library

CalePHP is in a subdirectory "Tor".

"http://localhost/Tor/admin/acl/aros" results in the manage aros page showing but a moment later it is replaced by a broken version of the page with database debug info. If I click the "stop" button at the right time, I can catch the original manage aros page. Its almost like a redirect somewhere is activated.
posted Mon, Mar 3rd 2008, 19:58 by Peter Fogg

Comment

22 Requires Alias

If you install this plugin, but none of your ACO/ARO records are appearing then it's probably because you're not using aliases. This plugin needs you to set an alias for it to function correctly.
posted Tue, Mar 4th 2008, 08:33 by Matt Curry

Comment

23 Plugin not working correctly.

Thanks for the comment. However, it turns out that what I was observing was occurring because I had the debug set to 2. Once it was changed to 1, the pages rendered correctly.
posted Tue, Mar 4th 2008, 13:26 by Peter Fogg

Bug

24 Not working when DB is initialized with zero records

Thanks Jeff for nice plug in .But i am having a problem . I have initialized db and there is no record yet. I am unable to create new aco / aro . Can any one help me ??? .

And one more question ! Can any one simulate a scenario on DEMO site http://dev.newnewmedia.com/cakephp/admin/acl

e.g for Post vs User/Groups such that
Post
-add
-edit
-view
-delete
-admin_add
-admin_edit
-admin_view
-admin_delete
-admin-verify
Group
(root) SuperAdmin Has all rights
/create group
/create user
/create acos/aros and permissions
Mediators - cannot delete
Users - can post /and edit his own posts




An how about if we can list controllers dynamically as acos and their actions . Is not that be good if we can create alias and keys values for the acos/and aros dynamically .

Thanks in advance for your time and knowledge .
posted Wed, Mar 5th 2008, 00:13 by s a khan

Question

25 please dont hit me

but i've a problem to set up the application. i get the error "Fatal error: Class 'AclAppController' not found in .... controllersacl_controller.php on line 3"
the acl_app_controller.php is in the app directory and the other controllers in the same named folder....
posted Sun, Mar 9th 2008, 09:26 by paulr

Comment

26 Tango link is broken

Google says to go here instead:
http://tango.freedesktop.org/Tango_Icon_Library
posted Wed, Mar 19th 2008, 16:05 by ambiguator

Comment

27 IE7 not loading AJAX dropdowns

Brilliant plugin! With minor issues works also under 1.2-alpha release.

The only biggish issue I am having is with compatibility with IE7. It doesnt load AJAX dropdowns for some reason. Any clues why? Its OK under Firefox.
posted Thu, Apr 17th 2008, 06:37 by Marek

Comment

28 IE problem

Loading ajax request results to the select tags doesn't work for IE, because there is restriction for texts which can be there loaded. To fix it you should put select into div and render whole div.

Please read:
http://forum.mootools.net/topic.php?id=4186#post-39085
posted Thu, Apr 17th 2008, 08:06 by Jan Szoja

Login to Submit a Comment