|

CakePHP ACL Tutorial: How To Check Access

View full index of ACL Tutorial Articles

To include the ACL Component in your application, add the following declaration into your AppController:

var $components = array('Acl');

Note that if you are using the Authorization Component, you will also need to include the Auth component in the same array, and it must appear after the Acl inclusion. In such a case, you would add this:

var $components = array('Acl', 'Auth');

Once your application is equipped with the ACL Component, you determine access to particular pages of a site by calling the Acl::check() function.

If the url being accessed is:

http://www.cakephp.org/recipes/view/23

and the logged-in user has a username of betty, and there is a corresponding ARO record with an alias of betty, you would do the following to check if access is allowed:

$this->Acl->check('betty', 'Recipes', 'read')

A really great resource for examples of how to call the Acl’s various functions from within code is the ACL Test Case.

By spending time looking at this file until you understand everything going on inside it, you will definately come along ways towards fully understanding how to correctly use the ACL Component.

The built-in Authentication Component and the ACL Behavior both take care of a lot of this core functionality automatically. I will focus more directly on these elements at another time.

Monday April 14, 2008

|

rss feed iconRSS / Atom

Aran World

My Amazon.com Wish List

I'm Aran Johnson and I make websites.

I primarily use: PHP, MySQL, SubVersion, CakePHP, TextPattern, Cream Text Editor, and Addi Turbo Needles

Contact Me

My website portfolio

Recently

Oakland Parking Violations and Fines

Tweet Design

CakePHP ACL and Auth: Record Level Protection

How To Play Hearts With Only Two Players

Facebook Privacy Settings

CakePHP Tutorials

CakePHP ACL and Auth: Record Level Protection

CakePHP ACL and Auth: Sample Website

CakePHP ACL and Auth Tutorial: Database Setup

CakePHP ACL Tutorial: Introduction

CakePHP ACL Tutorial: Usage With Auth Component

CakePHP ACL Tutorial: Initial Setup

CakePHP ACL Tutorial: Auth Component Example

CakePHP ACL Tutorial: How To Check Access

Cake PHP ACL Tutorial: The Database Tables

My Flickr

Advertisement:
Protect Your LCD or Plasma TV Screen From Accidents

All content © Aran Johnson