Return to Snippet

Revision: 68909
at March 16, 2015 21:58 by cakephpexpert


Initial Code
http://www.cakephpexpert.com/blog/cakephp-security-tips-and-tricks

Initial URL
http://www.cakephpexpert.com/blog/cakephp-security-tips-and-tricks

Initial Description
<p>Follow these steps to secure your Cakephp Website:</p>

<p>*Before you actually start using Security Component functionality, make sure you use $components = array (‘Security’, ‘Auth’) in the array so you can extend its functionality in the other components as well.</p>

<p>*Set security level "Medium" or "High" (in core.php config file)</p>

<p>*Add single line of code to your controller’s before Filter () method: $this->Security->requireAuth(‘action_name’) </p>

<p><strong>To assure more security, add few more lines of code in controller section:</strong></p>

<p><code>$key = Security::generateAuthKey ();
$this->set (‘safe’, $key);
$this->Session->write (‘safe’, $key);</code></p>

<p><strong>Or alternatively adding this code sequence in your view</strong></p>

<p><code>echo $this->Form->create(‘Post’);
echo $this->Form->hidden(‘safe’, $safe);
echo $this->Form->input(‘title’);
echo $this->Form->input(‘content’);
echo $this->Form->end(‘Submit’);</code></p>

Initial Title
Secure Your Cakephp Website By Following These Simple Steps!

Initial Tags
cakephp, security, web, Development

Initial Language
PHP