<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Azure Web Design &#187; CakePHP</title>
	<atom:link href="http://www.azurewebdesign.com/category/php/cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.azurewebdesign.com</link>
	<description>We Know Web</description>
	<lastBuildDate>Thu, 15 Apr 2010 04:28:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>CakePHP Authentication, Authorization and ACL</title>
		<link>http://www.azurewebdesign.com/cakephp-authentication-authorization-and-acl/</link>
		<comments>http://www.azurewebdesign.com/cakephp-authentication-authorization-and-acl/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 07:59:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.azurewebdesign.com/?p=200</guid>
		<description><![CDATA[What&#8217;s the difference between Authentication and Authorization? These two terms are quite often misunderstood. Let&#8217;s put it this way, suppose you work in a 100-story office building, each floor has different offices of other companies. You are working on the 49th Floor, cubicle number 20. Authentication is when the security personnel at the building&#8217;s front [...]]]></description>
			<content:encoded><![CDATA[<h2>What&#8217;s the difference between Authentication and Authorization?</h2>
<p>These two terms are quite often misunderstood. Let&#8217;s put it this way, suppose you work in a 100-story office building, each floor has different offices of other companies. You are working on the 49th Floor, cubicle number 20. Authentication is when the security personnel at the building&#8217;s front door allows you to come in. Authorization on the other hand, is when you have permission to get to your cubicle, log in to your computer and perform the tasks that you are permitted to do.</p>
<p>So being Authenticated does not automatically mean Authorized, but being Authorized would have to mean you are Authenticated.</p>
<h2>Using Basic CakePHP Authentication</h2>
<p>The first step is to include the <a href="http://book.cakephp.org/view/172/Authentication">Auth component</a> in your controller. If you are going to use Auth for the whole site, you would want to put this in your /app/app_controller.php.</p>
<pre lang="php">class AppController extends Controller {
 var $components = array('Auth');

 function beforeFilter() {
 //Configure Auth settings
 $this-&gt;Auth-&gt;loginError = "No, you fool! That's not the right password!";
 $this-&gt;Auth-&gt;authError = "Please sign in.";

 //$this-&gt;Auth-&gt;loginAction = array('controller' =&gt; 'users', 'action' =&gt; 'login');
 //$this-&gt;Auth-&gt;loginRedirect = array('controller' =&gt; 'users', 'action' =&gt; 'login');
 //$this-&gt;Auth-&gt;logoutRedirect = array('controller' =&gt; 'users', 'action' =&gt; 'login');

 if($this-&gt;Auth-&gt;user()) {
 //Our user is logged in.
 //User data is stored in $this-&gt;Session-&gt;read('Auth');
 }
}</pre>
<p>Then in your controllers, for example users_controller.php.</p>
<pre lang="php">function beforeFilter() {
 parent::beforeFilter(); //This line inherits beforeFilter() from app_controller.php
 $this-&gt;Auth-&gt;deny('*'); //Disallow access to all actions
 $this-&gt;Auth-&gt;allow('register','logout'); //Allow access to register() and logout()
}</pre>
<h2>Using <a href="http://book.cakephp.org/view/396/authorize">CakePHP Authorization</a></h2>
<p>Add the following code to /app/app_controller.php beforeFilter(). Auth-&gt;authorize accepts four types, &#8220;controller&#8221;, &#8220;model&#8221;, &#8220;actions&#8221;, &#8220;crud&#8221;. See the <a href="http://book.cakephp.org/view/396/authorize">CakePHP manual on Authorization</a> for details.</p>
<pre lang="php"> //Auth method. If set to controller,
 $this-&gt;Auth-&gt;authorize = 'controller';</pre>
<p>If Auth-&gt;authorize is set to &#8220;controller&#8221;, you&#8217;ll need to add a method called isAuthorized() to your controller. This method allows you to do some more authentication checks and then return either true or false. In this case, we put isAuthorized() into our users_controller.php</p>
<pre lang="php">function isAuthorized() {
 if( $this-&gt;action=='index' || $this-&gt;action=='view' || $this-&gt;action=='add' || $this-&gt;action=='edit' || $this-&gt;action=='delete') {
 if($this-&gt;Auth-&gt;user('group_id')==4)
 return true;
 }
 //Redirect to error notification page
 $this-&gt;Session-&gt;setFlash('Sorry, you don\'t have permission to access that page.');
 $this-&gt;redirect('/');
 return false;
}</pre>
<h2>Using <a href="http://book.cakephp.org/view/171/Access-Control-Lists">CakePHP ACL (Access Control Lists)</a></h2>
<p>This topic is a wee bit more complicated. I did not proceed using ACL because CakePHP&#8217;s Authorization was enough for my needs. ACL is a lot more flexible in granting and denying permissions. Granting and denying access to our users using ACL is quite complicated, fortunately somebody created a <a href="http://conseil-recherche-innovation.net/authake">CakePHP ACL Management Plugin</a>. It might still take a little while for CakePHP&#8217;s ACL to get easier to implement.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.azurewebdesign.com/cakephp-authentication-authorization-and-acl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CakePHP cookies not being written when localhost is used as domain</title>
		<link>http://www.azurewebdesign.com/cakephp-cookies-not-being-written-when-localhost-is-used-as-domain/</link>
		<comments>http://www.azurewebdesign.com/cakephp-cookies-not-being-written-when-localhost-is-used-as-domain/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 09:32:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.azurewebdesign.com/blog/?p=56</guid>
		<description><![CDATA[I just burned 4 hours of my time trying to figure out why CakePHP wouldn&#8217;t write cookies. Apparently there is a known problem with using $this-&#62;Cookie-&#62;domain = &#8216;localhost&#8217; , thanks to Flxr from the IRC for pointing that out. After making a virtual domain for the site, it worked wonderfuly!]]></description>
			<content:encoded><![CDATA[<p>I just burned 4 hours of my time trying to figure out why CakePHP wouldn&#8217;t write cookies.</p>
<p>Apparently there is a known problem with using $this-&gt;Cookie-&gt;domain = &#8216;localhost&#8217; , thanks to Flxr from the IRC for pointing that out.</p>
<p>After making a virtual domain for the site, it worked wonderfuly!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.azurewebdesign.com/cakephp-cookies-not-being-written-when-localhost-is-used-as-domain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pulling in WordPress Content in your CakePHP Website</title>
		<link>http://www.azurewebdesign.com/pulling-in-wordpress-content-in-your-cakephp-website/</link>
		<comments>http://www.azurewebdesign.com/pulling-in-wordpress-content-in-your-cakephp-website/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 15:05:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.azurewebdesign.com/blog/?p=28</guid>
		<description><![CDATA[Integrating your WordPress posts into your CakePHP website is easy. WebDevKungFu has an excellent post, just follow the step by step instruction. To this post, I just had to modify a line of code to further filter out what WordPress content (posts and published only) comes out as headlines From his code, add the following: [...]]]></description>
			<content:encoded><![CDATA[<p>Integrating your WordPress posts into your CakePHP website is easy.</p>
<p>WebDevKungFu has an excellent post, just follow the step by step instruction. <span id="more-28"></span></p>
<p>To this post, I just had to modify a line of code to further filter out what WordPress content (posts and published only) comes out as headlines</p>
<p>From his code, add the following:<br />
<code>$posts = $this-&gt;Blog-&gt;findAll(array(’post_status’ =&gt; ’publish’, 'post_type’ =&gt; ’post’),null,’post_date DESC’,3);</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.azurewebdesign.com/pulling-in-wordpress-content-in-your-cakephp-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
