←CakePHP ACL Tutorial: Auth Component Example| CakePHP ACL Tutorial: Usage With Auth Component→
View full index of ACL Tutorial Articles
To begin using the ACL Component, you must first create the database tables required by the component.
Using the Cake Console, you can run the following command to generate the required tables.
cake schema run create DbAcl
This replaces the older deprecated command, ‘initdb’.
If you are unable to run the console command, you can use the DbAcl Schema File as a guide to help you manually create your own database tables.
Once the database is configured, you will need to create some ACO and ARO rows in order to start using it.
Again, the Cake Console can be used to create elements in your ACL system. The following command within the cake console will help provide some insight into how to use this feature:
cake acl help
There is a lot of flexibility with how you create and name your own ACL elements, so it is important to consider your own needs when planning this out. However, the following series of commands might represent a common set of commands to run when initializing an ACL setup.
cake acl create aro ROOT guests
cake acl create aro guests users
cake acl create aro users admins
cake acl create aro users betty
cake acl create aco ROOT site
cake acl create aco site Articles
cake acl create aco site Recipes
cake acl create aco site Lists
cake acl grant admins site *
cake acl grant users Articles read
cake acl grant users Recipes read
cake acl grant betty Recipes update
You should now be able to run the following commands with the displayed results:
cake acl check betty Recipes read
--> betty is allowed
cake acl check betty Recipes delete
--> betty is not allowed
cake acl check admins Lists create
--> admins is allowed
If this is all working so far, you might want to dig into your database and take a look at the database tables for a better understanding of what a functioning ACL system looks like.
More information about the ACL Component’s database tables.
Tuesday April 15, 2008
←CakePHP ACL Tutorial: Auth Component Example| CakePHP ACL Tutorial: Usage With Auth Component→
I'm Aran Johnson and I make websites.
I primarily use: PHP, MySQL, SubVersion, CakePHP, TextPattern, Cream Text Editor, and Addi Turbo Needles
GlaxoSmithKline Give Canadians The Facts; Keeps Americans In the Dark
Why Joyent Is So Much Better Than Hostway