tags:

views:

337

answers:

2

Hi , I'm a newbie to CakePHP components. I had built a CakePHP application which has a login feature. I had not used "Auth" component but was using my custom method for authenticating.

Now I want to use the 'Acl' component in the same appllication but I'm unable to do so because it requires the "Auth" component also.

Is it possible to use 'Acl' without "Auth". If so, can anyone give some pointers?

+1  A: 

It is possible to use them separately, at least according to the Cake PHP Manual. As long as you can link your authenticated users to an ARO in the database it should work. You can see some of the basics on CakePHP ACL here: http://book.cakephp.org/view/465/Understanding-How-ACL-Works and here's a decent tutorial on setting up ACL: http://bakery.cakephp.org/articles/view/user-permissions-and-cakephp-acl

If you don't have your users in the database that makes it a little trickier. As long you can retrieve an ARO that has the required permissions after login you should be OK.

dmertl
A: 

Yes it is possible - as long as you link your user accounts with ACL everything should be ok.

Let's say your users log in using their e-mail and password then your ARO table in alias field can contain the e-mail address and foreign_id pointing to the id of your users table.

Once you have all the ACOs in place checking for permissions can be done using

$res =  $this->Acl->check(
        $us, // user alias (e-mail)
        $this->name, // name of the controller
        $privilege // privilege i.e. 'read' or '*'
        );
    return $res;

called in your beforeFilter of AppController

Plugawy