O'Reilly logo

CakePHP 2 Application Cookbook by Jorge González, James Watts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with ACL

When your application needs a powerful and flexible authentication mechanism, it's probably time to use the Access Control Lists (ACL) component, included with CakePHP.

Although you can use a file to manage your ACL configuration, storing all of the data in the database is the most common option, as we'll see in this recipe.

Getting ready

For this recipe, we'll use a users table as well as a roles table to allow us to define roles and inherit their permissions. For this, we'll use the following SQL statements:

CREATE TABLE users ( id VARCHAR(36) NOT NULL, username VARCHAR(255) NOT NULL, password VARCHAR(128) NOT NULL, active TINYINT(1) DEFAULT '0', role_id VARCHAR(36) DEFAULT NULL, created DATETIME DEFAULT NULL, modified DATETIME ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required