PHPackages                             friendsofcake/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. friendsofcake/authenticate

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

friendsofcake/authenticate
==========================

CakePHP plugin with authentication classes for AuthComponent.

2.0.0(10y ago)8243.6k↓50%40[1 issues](https://github.com/FriendsOfCake/Authenticate/issues)1MITPHPPHP &gt;=5.4.0

Since Sep 13Pushed 9y ago4 watchersCompare

[ Source](https://github.com/FriendsOfCake/Authenticate)[ Packagist](https://packagist.org/packages/friendsofcake/authenticate)[ Docs](http://github.com/FriendsOfCake/Authenticate)[ RSS](/packages/friendsofcake-authenticate/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (9)Used By (1)

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

[](#authenticate-plugin)

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

NOTE: This project is no longer maintained actively.
====================================================

[](#note-this-project-is-no-longer-maintained-actively)

The Authenticate classes have become redundant or better alternatives have surfaced:

- MultiColumnAuthenticate, see [Tools](https://github.com/dereuromark/cakephp-tools) - or use custom finders in CakePHP 3
- CookieAuthenticate, see [Xety/Cake3-CookieAuth](https://github.com/Xety/Cake3-CookieAuth)
- TokenAuthenticate, see [JwtAuth](https://github.com/ADmad/cakephp-jwt-auth)

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

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

[](#requirements)

- CakePHP 3.0

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

[](#installation)

*\[Composer\]*

run: `composer require friendsofcake/authenticate:dev-cake3` or add `"friendsofcake/authenticate":"dev-cake3"` to `require` section in your application's `composer.json`.

Usage
-----

[](#usage)

In your app's `config/bootstrap.php` add: `Plugin::load('FOC/Authenticate');`

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

[](#configuration)

Setup the authentication class settings

### MultiColumnAuthenticate:

[](#multicolumnauthenticate)

```
    //in $components
    public $components = [
        'Auth' => [
            'authenticate' => [
                'FOC/Authenticate.MultiColumn' => [
                    'fields' => [
                        'username' => 'login',
                        'password' => 'password'
                    ],
                    'columns' => ['username', 'email'],
                    'userModel' => 'Users',
                    'scope' => ['Users.active' => 1]
                ]
            ]
        ]
    ];

    // Or in beforeFilter()
    $this->Auth->config('authenticate', [
        'FOC/Authenticate.MultiColumn' => [
            'fields' => [
                'username' => 'login',
                'password' => 'password'
            ],
            'columns' => ['username', 'email'],
            'userModel' => 'Users',
            'scope' => ['Users.active' => 1]
        ]
    ]);
```

### CookieAuthenticate:

[](#cookieauthenticate)

```
    //in $components
    public $components = [
        'Auth' => [
            'authenticate' => [
                'FOC/Authenticate.Cookie' => [
                    'fields' => [
                        'username' => 'login',
                        'password' => 'password'
                    ],
                    'userModel' => 'SomePlugin.Users',
                    'scope' => ['User.active' => 1]
                ]
            ]
        ]
    ];
    //Or in beforeFilter()
    $this->Auth->authenticate = [
        'FOC/Authenticate.Cookie' => [
            'fields' => [
                'username' => 'login',
                'password' => 'password'
            ],
            'userModel' => 'SomePlugin.Users',
            'scope' => ['Users.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 = [
        'Auth' => [
            'authenticate' => [
                'FOC/Authenticate.Cookie' => [
                    'fields' => [
                        'username' => 'login',
                        'password' => 'password'
                    ],
                    'userModel' => 'SomePlugin.Users',
                    'scope' => ['User.active' => 1]
                ],
                'FOC/Authenticate.MultiColumn' => [
                    'fields' => [
                        'username' => 'login',
                        'password' => 'password'
                    ],
                    'columns' => ['username', 'email'],
                    'userModel' => 'Users',
                    'scope' => ['Users.active' => 1]
                ]
            ]
        ]
    ];
```

### Setting the cookie

[](#setting-the-cookie)

Example for setting the cookie:

```
