29 December 2009

Salt and Passwords

To find out what a generated hashed password would look like, do this...

$this->Auth->password('password');


The salt Security.salt found in app\config\core.php affects the generated hashed password.

06 November 2009

One core, many apps

Edit this ~/www/ampcake/app/webroot/index.php

CAKE_CORE_INCLUDE_PATH can either be relative (../../core) or absolute (/path/to/core)

For our case, 'cakephp' stores the 'cake' library. This works for both dev and live environment.

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if ($_SERVER['SERVER_NAME'] == 'localhost') {
define('CAKE_CORE_INCLUDE_PATH', '..' . DS . '..' . DS . 'cakephp');
} else {
define('CAKE_CORE_INCLUDE_PATH', ROOT);
}
}

05 November 2009

Bake Cake on Windows

Assuming that the required tables that conforms to cakephp standard is already in the database.

On a Windows machine, setup environment variable pointing to both "php.exe" and "cake.exe"

Change directory into "C:\www\ampcake\app", paying extra attention that you are really in the "app" directory.

Run "cake bake all" and follow the instructions on screen.

21 May 2009

Enable and disable site in Apache2

To enable a site.
a2ensite

And to disable a site.
a2dissite

Update apache2 configuration and reload, run this command:
/etc/init.d/apache2 reload

12 February 2009

Apache and PHP5

On a Linux box, in order for PHP5 to work with Apache2, you need these installed:

php5
php5-common
libapache2-mod-php5


Additionally, if you would like to have PostgeSQL support, you will need this as well:

php5-pgsql

21 July 2008

Creating ACL in CakePHP

Notes:

acl (access control list)
aro (access request object)
aco (access control object)


Make sure that /app/config/database.php is present and configured properly.
Next, user the CakePHP console to create the ACL database tables:

cake schema run create DbAcl



Follow the instructions on the screen to create or drop any existing ACL database tables.

To get an idea of what cake acl can offer, run this:

cake acl help



To create some top level (root) aros:

cake acl create aro root warriors
cake acl create aro root wizards
cake acl create aro root hobbits
cake acl create aro root visitors


Running the view command, you'll see a tree structure of the aros:

cake acl view aro

Aro tree:
[20]warriors
[21]wizards
[22]hobbits
[23]visitors



Create some second level aros:

cake acl create aro warriors Aragorn
cake acl create aro warriors Legolas
cake acl create aro warriors Gimli
cake acl create aro wizards Gandalf
cake acl create aro hobbits Frodo
cake acl create aro hobbits Bilbo
cake acl create aro hobbits Merry
cake acl create aro hobbits Pippin
cake acl create aro visitors Gollum


cake acl view aro

Aro tree:
[20]warriors
[25]Aragorn
[26]Legolas
[27]Gimli
[21]wizards
[28]Gandalf
[22]hobbits
[24]Frodo
[29]Bilbo
[30]Merry
[31]Pippin
[23]visitors
[32]Gollum



To create some top level (root) acos:

cake acl create aco root Weapons
cake acl create aco root Rings
cake acl create aco root PorkChops
cake acl create aco root DiplomaticEfforts
cake acl create aco root Weapons


Similarly, to view the acos:

cake acl view aco

Aco tree:
[1]Weapons
[2]Rings
[3]PorkChops
[4]DiplomaticEfforts
[5]Ales



To set permissions to the aros, grant warriors full access (create, read, update, delete) to the Weapons.

cake acl grant warriors Weapons all


Since Legola is part of the warriors, thus Legolar inherits the grant as well.

cake acl check Legolas Weapons read

Legolas is allowed.


Specifically denying Legolas read access to the Weapons.

cake acl deny Legolas Weapons read


Running a check will show that Legolas still has other access.

cake acl check Legolas Weapons read

Legolas is not allowed.


cake acl check Legolas Weapons create

Legolas is allowed.

20 July 2008

MySQL Data Dump

Dumping data into a MySQL database.
mysql -u USERNAME -p DATABASE < dump.sql