|
| 1 | +# Authorize plugin |
| 2 | + |
| 3 | +Plugin containing some authorize classes for AuthComponent. |
| 4 | + |
| 5 | +Current classes: |
| 6 | +- AclAuthorize, row based Acl. AuthComponent adapter, to use together with AclBehavior created acos |
| 7 | +- HabtmDbAcl. AclComponent adapter, for User habtm Group Acl. (for database acl only) |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +- PHP 5.2.8 |
| 12 | +- CakePHP 2.x |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +_[Manual]_ |
| 17 | + |
| 18 | +- Download this: http://github.com/FriendsOfCake/Authorize/zipball/master |
| 19 | +- Unzip that download. |
| 20 | +- Copy the resulting folder to app/Plugin |
| 21 | +- Rename the folder you just copied to Authorize |
| 22 | + |
| 23 | +_[GIT Submodule]_ |
| 24 | + |
| 25 | +In your app directory type: |
| 26 | +``` |
| 27 | +git submodule add git://github.com/FriedsOfCake/Authorize.git Plugin/Authorize |
| 28 | +git submodule init |
| 29 | +git submodule update |
| 30 | +``` |
| 31 | + |
| 32 | +_[GIT Clone]_ |
| 33 | + |
| 34 | +In your plugin directory type |
| 35 | +``` |
| 36 | +git clone git://github.com/FriendsOfCake/Authorize.git Authorize |
| 37 | +``` |
| 38 | + |
| 39 | +## Usage |
| 40 | + |
| 41 | +In `app/Config/bootstrap.php` add: `CakePlugin::load('Authorize');` |
| 42 | + |
| 43 | +## Configuration AclAuthorize: |
| 44 | + |
| 45 | +Setup the authorize class |
| 46 | + |
| 47 | +Example: |
| 48 | +```php |
| 49 | + //in $components |
| 50 | + public $components = array( |
| 51 | + 'Auth' => array( |
| 52 | + 'authorize' => array( |
| 53 | + 'Controller', |
| 54 | + 'Authorize.Acl' => array('actionPath' => 'Models/') |
| 55 | + ) |
| 56 | + ) |
| 57 | + ); |
| 58 | + //Or in beforeFilter() |
| 59 | + $this->Auth->authorize = array( |
| 60 | + 'Controller', |
| 61 | + 'Authorize.Acl' => array('actionPath' => 'Models/') |
| 62 | + ); |
| 63 | +``` |
| 64 | +In the above example `ControllerAuthorize` is checked first. If your `Controller::isAuthorized()` |
| 65 | +returns true on admin routing, AclAuthorize will only be checked for non-admin urls. |
| 66 | +Also you need to set `actionPath` in a similar way which is used with Actions- and CrudAuthorize. |
| 67 | + |
| 68 | +## Configuration HabtmDbAcl: |
| 69 | + |
| 70 | +Setup the HabtmDbAcl adapter |
| 71 | + |
| 72 | +in app/Config/core.php |
| 73 | +```php |
| 74 | +Configure::write('Acl.classname', 'Authorize.HabtmDbAcl'); |
| 75 | +``` |
| 76 | + |
| 77 | +Make sure if you need to alter settings for HabtmDbAcl, you pass those to |
| 78 | +AclComponent ``$settings['habtm']``, and have it loaded before any Auth configuration. |
| 79 | +```php |
| 80 | + //in $components |
| 81 | + public $components = array( |
| 82 | + 'Acl' => array('habtm' => array( |
| 83 | + 'userModel' => 'Users.User', |
| 84 | + 'groupAlias' => 'Group' |
| 85 | + )), |
| 86 | + 'Auth' => array( |
| 87 | + //your Auth settings |
| 88 | + ) |
| 89 | + ); |
| 90 | +``` |
0 commit comments