Archives
Recent posts
Recent comments
- In Benchmarking requestAction
- David wrote: Why you are not counting database connection impact? Is it really so unimportant?
- In Nate Abele - PHP is dying
- Victor wrote: When you say the following: "[PHP] is just too simple. It requires only a few lines to generate...
- In Felix Geisendörfer - Git and CakePHP
- Josh wrote: I'd really like to figure out a way to clone the official git repo and merge it with my own in a...
- In Martin Radosta - Record level security based on SQL
- markstory wrote: Well the article was about a talk that Martin Radosta gave. I have not written this behavior. ...
- In Martin Radosta - Record level security based on SQL
- skitle wrote: Was curious if the files for this are available? I have searched through the SF site, and have...
Categories
Jeff Loiselle - Authentication & Authorization with CakePHP
Written on Thu, Dec 4th 2008, 08:43 in CakeFest, CakePHP
Why authorize and authenticate?
Authorization ensures someone is who they say they are. Restricting access is a separate process. Authorization is done in CakePHP with Auth Component. Auth works with a database by default, but it can be changed to work with anything. LDAP, Radius, and OpenID are some examples of alternate authentication sources. Auth component has a number of benefits. It hashes passwords, and it provides one API for all authentication sources.
Setting up AuthComponent
Need to setup a users table and create a user model. You should have a username and password field. This will help you make the most of the intelligent defaults built into Auth. After that you need to add Auth to you controllers var $components.
Acl component
Has an easy to use API, identifies, create nodes, checks permissions. The ACL component handles hierarchies with ease, which allows inheritance permission systems.
Auth modes and simple auth.
Auth component has a number of modes, each handles authorization in a different situation. Jeff did a live demo of setting up the ACL tables. Jeff setup the acl tables with cake acl initdb. After the acl tables were set up Jeff covered creating a simple login form and easy Auth.
Using Auth and Acl's together.
Before you can start using Auth and Acl together, you need some aros and acos. Jeff used his Acl management plugin to quickly create some aros and acos, as well as set the permissions for his new user and controllers.
Jeff then demonstrated how to use to the AuthComponent in crud mode. Jeff ran out of time, but covered a few good options for handling Auth and ACL.

What is OpenID?
OpenID is a new open standard that lets you sign in to web sites with a single URL that you own. This URL can be your homepage or blog, or it can be provided to you by a web site you use. In either case, you only have to sign in once to your OpenID provider and so you only need to maintain a single password.Learn more.
How is CakeDC using OpenID?
You can use your OpenID identity when posting comments on the site. When you see a form field with
entering your OpenID identity is sufficient to allow your post. We also accept Google or Yahoo! identities. Simply use either "google.com" or "yahoo.com" and our OpenID library will locate your information from the appropriate source.
Comments:
Add comment