Plugin containing some authenticate classes for AuthComponent.
Current classes:
- MultiColumnAuthenticate, allow login with multiple db columns in single username field
For example username or email - CookieAuthenticate, login with a cookie
- PHP 5.3
- CakePHP 2.x
[Manual]
- Download this: http://github.com/ceeram/Authenticate/zipball/master
- Unzip that download.
- Copy the resulting folder to app/Plugin
- Rename the folder you just copied to Authenticate
[GIT Submodule]
In your app directory type:
git submodule add git://github.com/ceeram/Authenticate.git Plugin/Authenticate
git submodule init
git submodule update
[GIT Clone]
In your plugin directory type
git clone git://github.com/ceeram/Authenticate.git Authenticate
In app/Config/bootstrap.php add: CakePlugin::load(‘Authenticate’);
Setup the authentication class settings
Example for MultiColumnAuthenticate:
//in $components
public $components = array(
'Auth' => array(
'authenticate' => array(
'Authenticate.MultiColumn' => array(
'fields' => array(
'username' => 'login',
'password' => 'password'
),
'columns' => array('username', 'email'),
'userModel' => 'User',
'scope' => array('User.active' => 1)
)
)
)
);
//Or in beforeFilter()
$this->Auth->authenticate = array(
'Authenticate.MultiColumn' => array(
'fields' => array(
'username' => 'login',
'password' => 'password'
),
'columns' => array('username', 'email'),
'userModel' => 'User',
'scope' => array('User.active' => 1)
)
);
Example for CookieAuthenticate:
//in $components
public $components = array(
'Auth' => array(
'authenticate' => array(
'Authenticate.Cookie' => array(
'fields' => array(
'username' => 'login',
'password' => 'password'
),
'userModel' => 'SomePlugin.User',
'scope' => array('User.active' => 1)
)
)
)
);
//Or in beforeFilter()
$this->Auth->authenticate = array(
'Authenticate.Cookie' => array(
'fields' => array(
'username' => 'login',
'password' => 'password'
),
'userModel' => 'SomePlugin.User',
'scope' => array('User.active' => 1)
)
);
Example to setup both, it will first try to read the cookie, if that fails will try with form data:
//in $components
public $components = array(
'Auth' => array(
'authenticate' => array(
'Authenticate.Cookie' => array(
'fields' => array(
'username' => 'login',
'password' => 'password'
),
'userModel' => 'SomePlugin.User',
'scope' => array('User.active' => 1)
),
'Authenticate.MultiColumn' => array(
'fields' => array(
'username' => 'login',
'password' => 'password'
),
'columns' => array('username', 'email'),
'userModel' => 'User',
'scope' => array('User.active' => 1)
)
)
)
);
For enhanced security, make sure you add this code to your AppController::beforeFilter() if you intend to use Cookie authentication:
public function beforeFilter() {
$this->Cookie->type('rijndael'); //Enable AES symetric encryption of cookie
}
Read more on the wiki: https://github.com/ceeram/Authenticate/wiki/Set-Cookie
Copyright © 2012 Ceeram
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.