PHPackages                             ceeram/authenticate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ceeram/authenticate

ActiveCakephp-plugin[Authentication &amp; Authorization](/categories/authentication)

ceeram/authenticate
===================

CakePHP plugin with authentication classes for AuthComponent.

1.0.0(12y ago)51.3k4MITPHP &gt;=5.3.0

Since Sep 13Pushed 11y ago2 watchersCompare

[ Source](https://github.com/ceeram/Authenticate)[ Packagist](https://packagist.org/packages/ceeram/authenticate)[ Docs](http://github.com/ceeram/Authenticate)[ RSS](/packages/ceeram-authenticate/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

Authenticate plugin
===================

[](#authenticate-plugin)

[![Build Status](https://camo.githubusercontent.com/d810c2d7bb278c40ffde80e3a96f3abfbf0b5138c7706daf2455e881327e6a86/68747470733a2f2f7472617669732d63692e6f72672f467269656e64734f6643616b652f41757468656e7469636174652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/FriendsOfCake/Authenticate)[![Coverage Status](https://camo.githubusercontent.com/2db275d67b9dcd49f06a7988f43cb26517dc3ee2cb8b1d267f1fdc4161a872aa/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f467269656e64734f6643616b652f41757468656e7469636174652f62616467652e706e67)](https://coveralls.io/r/FriendsOfCake/Authenticate)

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
- TokenAuthenticate, login with a token as url parameter or header

GoogleAuthenticate is moved to separate repo:

Requirements
------------

[](#requirements)

- PHP 5.3
- CakePHP 2.x

Installation
------------

[](#installation)

*\[Composer\]*

run: `composer require friendsofcake/authenticate` or add `friendsofcake/authenticate` to `require` in your applications `composer.json`

*\[Manual\]*

- Download this:
- 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/FriendsOfCake/Authenticate.git Plugin/Authenticate
git submodule init
git submodule update

```

*\[GIT Clone\]*

In your plugin directory type `git clone git://github.com/FriendsOfCake/Authenticate.git Authenticate`

Usage
-----

[](#usage)

In `app/Config/bootstrap.php` add: `CakePlugin::load('Authenticate')`;

Configuration:
--------------

[](#configuration)

Setup the authentication class settings

### MultiColumnAuthenticate:

[](#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)
        )
    );
```

### CookieAuthenticate:

[](#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)
        )
    );
```

### Setup both:

[](#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)
                )
            )
        )
    );
```

### Security

[](#security)

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
}
```

### Setting the cookie

[](#setting-the-cookie)

Example for setting the cookie:

```
