ACL Management Plugin

by 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.

Report

More on Plugins

Tags

Advertising

Comments

  • Louis posted on 04/05/10 06:07:52 PM
    Thanks! Makes sense now.
  • Louis posted on 04/05/10 01:48:29 PM
    I am about ready to fire this plugin up, but I can't get the ACL plugin source from SVN! Can anyone please help me locate another copy of the source? Thank you in advance!

    Louis
  • brassman79 posted on 11/23/09 06:08:24 PM
    for us complete newbs...

    now that the code is on github how do we load this into our apps?

    I've got lots more folders in the tarball and don't know where they all go.

    thx for the help
  • grossman posted on 10/08/09 04:01:42 PM
    I can't to get the code from svn://newnewmedia.com/cakephp/plugins/acl
    and the source from http://github.com/phishy doesn't work also.

    Can anybody put the code to any other location?

    Thanks a lot.

    Mareg
  • Meroje posted on 06/30/09 01:46:26 PM
    Hello,
    I've just installed the plugin and initialize acl's tables in my BD with a script found here : http://www.formation-cakephp.com/32/gestion-des-droits-dacces-par-groupes-dutilisateurs-avec-acl (sorry im french) and the plugin donn't find anything and on all the plugin's page it show that there is no aros and acos.
    Do someone know why ?
  • cmnajs posted on 06/10/09 10:55:08 PM
    Hi
    Is ACL Management Plugin still available. I have tried to checkout but the repository is not available.
  • cmnajs posted on 06/10/09 05:10:07 AM
    I have tried to checkout the given svn path.
    svn://newnewmedia.com/cakephp/plugins/acl

    But i get the following error..

    Can't connect to host 'newnewmedia.com': No connection could be made because the target machine actively refused it.
    • womble posted on 06/25/09 12:38:36 AM
      I have tried to checkout the given svn path.
      svn://newnewmedia.com/cakephp/plugins/acl

      But i get the following error..

      Can't connect to host 'newnewmedia.com': No connection could be made because the target machine actively refused it.

      I couldn't get it either. But, think he's got a copy here http://github.com/phishy
  • leeherng posted on 05/17/09 07:49:56 AM
    Hi,

    I am having an issue while setting up CakePHP ACL Plugin.

    Missing Method in AclController
    Error: The action index is not defined in controller AclController

    Error: Create AclController::index() in file: admin\controllers\acl_controller.php.

    Could you please provide me some advice on this?

    Thanks
  • Theaxiom posted on 02/14/09 07:57:00 AM
    you can find the most updated version of this plug-in at the following URL: http://github.com/phishy/acl_plugin/tree/master
  • Edakos posted on 02/08/09 03:26:23 PM
    At the time of this writing, CakePHP has no way of bundling images/css/js within the plugin.
    You can put the images, js and css files into de vendors directory of your plugin.

    Ed
  • pepe posted on 01/27/09 09:51:01 AM
    Maybe helpful.

    When I tried to run the ACL admin, I ran into the following error:

    Fatal error: Class 'AclNode' not found in ../app/plugins/acl/models/acl_aco.php on line 7

    Adding the this piece of code to acl_aco.php and acl_aro.php solved the problem.


    <?php

    if (!class_exists('AclNode')) {
        
    uses('model' DS 'db_acl');
    }

    //Model code
    class AclAro extends AclNode {

    }
    ?>
  • webweave posted on 10/30/08 12:59:55 PM
    Looks like a good start.

    I'm seeing a couple of issues when running this locally though.

    My display doesn't look like your demo. I downloaded the latest from subversion, but I don't see the bits at the bottom of the page when assigning permissions (or more importantly, I have to click the lists again to see the updated permissions).

    I had to copy the acl.css to my webroot/css folder to get the right CSS on the pages (this seems to sort have fixed the issue with the debug too, since now it's all nicely formatted, although the debug code still shows up in the list boxes).

    Appears to me that the fix is to change the acl/views/layout/default.ctp at line 40 from:
    <?php echo $html->css('acl');?> To:
    <?php echo $html->css('/acl/css/acl');?>
  • Kumazatheef posted on 10/24/08 04:02:58 AM
    http://localhost/admin/acl does not work (Missing Controller error: "AclController");

    However, http://localhost/admin/acl/acl does work. Probably because the Book says plugins should be called like /pluginname/controllername/action.
    http://book.cakephp.org/view/119/Plugin-Tips
  • mork posted on 08/05/08 04:25:03 PM
    Hi
    it seems that I am unable to find the plugin.
    copied your plugin to my app/plugins
    saved prototype.js and tango icons
    enabled admin routing
    but it can't find it

    I use acl, and tried to add an aro for it and to allow me to access: no success

    Any hint? thanks!
    marco
  • reconbot posted on 08/03/08 01:08:39 AM
    Just so people know the tango project seems to have lost their domain, you can find the icons here.

    http://tango.freedesktop.org/releases/
    and the direct download

    http://tango.freedesktop.org/releases/tango-icon-theme-0.8.1.tar.gz
  • reconbot posted on 08/03/08 01:06:33 AM
    hi, I downloded SVN from http://tortoisesvn.tigris.org/.

    when i want to checkout then show failed.
    Checkout from http://dev.newnewmedia.com/cakephp/admin/acl, revision HEAD, Fully recursive, Externals included
    XML data was not well-formed
    Finished!
    why?

    That's the demo, while svn repo's can be accessed via http sometimes he has his setup via the svn protocol. The correct address is svn://newnewmedia.com/cakephp/plugins/acl
  • anisbd posted on 07/09/08 09:10:20 AM
    hi, I downloded SVN from http://tortoisesvn.tigris.org/.

    when i want to checkout then show failed.
    Checkout from http://dev.newnewmedia.com/cakephp/admin/acl, revision HEAD, Fully recursive, Externals included
    XML data was not well-formed
    Finished!
    why?
  • primerg posted on 07/01/08 12:57:55 AM
    How do you set permissions for a plugin? Example I have Pizza plugin and Order controller. How do I set that the Pizza.Order is available only for registered customers?
  • Vangel posted on 06/04/08 11:39:32 PM
    Hello Jeff,
    I really like your work. I use your versionbehavior as well which i took sometime to fgure out.

    Anyways, I cannot seem to get my hand on the acl plugin sources. the SVN doesnt exist. I tried cakeforge, your project is lsited but no files again.

    Is it not usable anymore?

    Thanks, this ACL plugin stuff looks great
  • twiof posted on 05/28/08 09:35:31 AM
    Just to give others a heads up: I needed to set debug to "0" as response times were being added to the string.

    To get arround it (temporarily) I used the following:

    /app/plugins/views/acl/admin_aros.cpt

    change:

    function (transport) {
    data = eval("("+transport.responseText+")");
    $('aro_editor_id').value = data.id;
    $('aro_editor_originalParentId').value = data.parent_id;
    $('aro_editor_alias').value = data.alias;
    $('aro_editor_model').value = data.model;
    $('aro_editor_foreignKey').value = data.key;
    $('aro_editor_create').hide();
    $('aro_editor_update').show();
    $('aro_editor_cancel').show();
    $('aro_editor_delete').show();
    indicator_hide();
    }});

    to:

    function (transport) {
    TspRsp = transport.responseText;
    TspRsp = TspRsp.split(",");

    idsplit = TspRsp[0].split('"');
    id = idsplit[3];

    aliasSplit = TspRsp[1].split('"');
    alias = aliasSplit[3];

    modelSplit = TspRsp[2].split('"');
    model = modelSplit[3];

    fkSplit = TspRsp[3].split('"');
    fk = fkSplit[3];

    $('aro_editor_id').value = id;
    $('aro_editor_alias').value = alias;
    $('aro_editor_model').value = model;
    $('aro_editor_foreignKey').value = fk;
    $('aro_editor_create').hide();
    $('aro_editor_update').show();
    $('aro_editor_cancel').show();
    $('aro_editor_delete').show();
    indicator_hide();
    }});

    Not elegant but did the trick.
  • brandos posted on 05/26/08 02:03:32 AM
    Hi Jeff Loiselle,

    I tried your demo of the acl manager and want to give it a try!

    But I get an error when I try to "browse" the link svn://newnewmedia.com/cakephp/plugins/acl (I use tortoise SVN)

    Can you double check that the files are in place?

    Regs and greets

    Par
  • mar3k posted on 04/17/08 06:37:01 AM
    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.
  • aaron posted on 03/19/08 04:05:50 PM
    Google says to go here instead:
    http://tango.freedesktop.org/Tango_Icon_Library
  • paulr posted on 03/09/08 09:26:44 AM
    but i've a problem to set up the application. i get the error "Fatal error: Class 'AclAppController' not found in .... \controllers\acl_controller.php on line 3"
    the acl_app_controller.php is in the app directory and the other controllers in the same named folder....
  • cucumucz posted on 03/05/08 12:13:01 AM
    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 .
  • peterhf posted on 03/04/08 01:26:16 PM
    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.
  • mattc posted on 03/04/08 08:33:52 AM
    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.
  • peterhf posted on 03/03/08 07:58:50 PM
    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.
  • blackymetal posted on 02/20/08 12:18:22 PM
    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!
  • sector7 posted on 01/29/08 08:14:44 AM
    apparently the command behaves differently when run from ROOT\cake\console\ AND ROOT\app\

    to people facing problems. run this cmd from ROOT\app. 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)
  • beautifiers posted on 01/08/08 08:28:09 PM
    hi jeff.
    I'm having problem opening the ur svn url. FYI i'm using kdesvn.
  • cucumucz posted on 12/14/07 01:10:19 AM
    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.
    • sector7 posted on 01/29/08 07:18:41 AM
      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?!
  • cucumucz posted on 12/14/07 01:02:33 AM
    In new released version cake_1.2.0.5875-pre-beta ,

     cake acl initdb 
    gives following error:

    ..\console\config\ not found


    Can any one help me sort out this bug ??

    Thanks in advance.
  • nozavroni posted on 12/09/07 04:45:44 PM
    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 app\views\errors\missing_controller.ctp

    Fatal: Create the class below in file: app\controllers\acl_controller.php

    class AclController extends AppController {
    var $name = 'Acl';
    }
    ?>
    What am I doing wrong?
  • Phillip posted on 12/02/07 10:49:43 PM
    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.
  • webbiz posted on 12/01/07 11:11:17 AM
    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.
    • FruitCake posted on 12/01/07 12:13:12 PM
      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
  • phishy posted on 11/26/07 06:01:27 AM
    i failed to mention i wrote this for php5. i'll rework it for php4 soon. stay tuned.
  • FruitCake posted on 11/20/07 03:50:27 PM
    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.4\vhosts\..\app\plugins\acl\controllers\acl_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() [CORE\html\plugins\acl\controllers\acl_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??
  • ionas posted on 11/20/07 10:43:01 AM
    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

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


    What should I do?
    • phishy posted on 11/20/07 11:31:37 AM
      sorry, i failed to mention in my tutorial that you need to turn on admin routing in your core.php config file.
  • Perkster posted on 11/15/07 01:38:38 PM
    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.
    • phishy posted on 11/16/07 09:43:07 AM
      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
  • rollo posted on 11/15/07 12:04:37 PM
    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!
  • helioricardo posted on 11/12/07 10:48:30 PM
    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
    • phishy posted on 11/14/07 06:20:06 AM
      I failed to mention that this was written for CakePHP 1.2. Is that the version you are using?
      • jmn2k1 posted on 11/14/07 07:44:52 AM
        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.
login to post a comment.