←CakePHP ACL and Auth Tutorial: Database Setup| November 4 Elections: a pattern?→
View full index of ACL Tutorial Articles
In order to demonstrate real-world usage of CakePHP’s ACL and Authentication Components, I have created a sample website.
The sample website features the following features in it’s current 1.0 version:
This sample code is NOT an example of how to safely collect data from users in online forms. I do almost no data validation in the content creation forms, and I don’t escape any characters in the views. With that in mind, this is only usable as a learning vehicle, and not as some sort of enterprise ready CMS!
You can get the source code from this website two ways:
To most quickly get up to speed with the sample site, follow these steps:
That should be all you have to do. After correctly being configured, you should be able to login as one of two users, each with separate permissions:
Pierre Herme - Superuser
username: pherme
password: ILikeCake
Elizabeth Crocker - User
username: ecrocker
password: outofbox
The website is simple enough, that you should be able to navigate it’s source code while reading other tutorials about ACL and Authentication and begin to get an idea of what you need to do to get it all working.
I will be writing some more articles providing some more detailed deconstructions of what is going on.
View full index of ACL Tutorial Articles
Monday May 26, 2008
Thank you for this great work. I’ve read many tutorials and other documentation to get this stuff together. But your sample project with the source is much more helpful for me. So with the additinal docs I’ve read, i will go further on cakePHP.
Thank you for all the works. Your demo project is very helpful and I started to understand how ACL works in CakePHP.
I tried to build a similar website with the logic you built but I have some questions on authorizing users permissions. I have a User model to store user accounts. Users can view the different user profiles but they can only edit their own profile. So I grant the user to “read” and “update” of the corresponding ACO of the user account. But I can’t achieve this. Only the admin user who have all permissions could run edit action. How can I do that?
wow. your kitchen really makes me feel that cakephp rocks.. i wish there would also a tutorial for image upload… thanks! aranworld.com rocks!
aha!
i figured out where some of the inconsistency lies within the views…
if you browse \views\articles\view.ctp the first line of code is a link using php to call $referrer. this causes the articles not to be able to find their article index
next navigate to views/secret_recipes/view.ctp
the view code for secret recipe type articles to find their way back to their index was written differently, and won’t need to be modified to work correctly. i used this for the model to fix the previous issue.
although a number of other links were still broken…
i think i had trouble grasping step 3…configure index.php to accurately reflect your own environment
villas mentioned how running the application outside your root directory caused problems, something about using link instead of url, i used dreamweaver to do a massive find/replace and it messed up the formatting of the site and caused other issues…so i scrapped those suggested changed.
instead to fix my links i went in and hardcoded a “/kitchen” in front of all the broken links, appearing in each view.
this is because most of the links would link to localhost/articles for instead, instead of localhost/kitchen/articles …
can someone reflect on the many errors of my ways?
@Glenn: I assume you are using Apache on Windows? And you probably have your sites served from addresses such as localhost/site1, localhost/site2, localhost/site3?
I used to do this, but now I have things set up so that my local sites are accessed like this: site1.localhost, site2.localhost, site3.localhost. In this latter case, then I can accurately use the “/” to indicate the root URL.
You want to read all about using Apache Vhosts. You will also have to become familiar with the Windows Hosts file. It is worth the time to figure this out, because you will find that your local web development server will more accurately reflect a live public web server.
Hi Aran,
Congratulations on the tutorial very easy to follow and understand. I have a question which I have been trying to answear myself by hardcoding some stuff myself. I am tryin to get the group model to update the aros whenever any of the group is changed.
For instance i have the following groups:
guests
members
bronze
silver
gold
managers
admins
whenever I try to modify the group name the aros are not updated and also I would like to know if you know a way which I can use to let content added to the db be only deleted edited by the person that added it or others with granted permissions.
Hope you can help.
Cheers
marcus
←CakePHP ACL and Auth Tutorial: Database Setup| November 4 Elections: a pattern?→
I'm Aran Johnson and I make websites.
I primarily use: PHP, MySQL, SubVersion, CakePHP, TextPattern, Cream Text Editor, and Addi Turbo Needles
New York Times Chocolate Chip Cookie Modification
GlaxoSmithKline Give Canadians The Facts; Keeps Americans In the Dark
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
I just downloaded your kitchen project. It was really great! I needed to alter some of the views to put html->link in place of the html->url. If you don’t run the project in the document_root the links won’t work otherwise. But really, thanks so much for putting this together. How on earth do you have enough time for knitting too!
— villas May 29, 04:32 PM #