PHP Класс FOC\Authenticate\Auth\TokenAuthenticate

Provides the ability to authenticate using Token $this->Auth->config('authenticate', [ 'FOC/Authenticate.Token' => [ 'parameter' => '_token', 'header' => 'X-MyApiTokenHeader', 'userModel' => 'Users', 'scope' => ['User.active' => 1] 'fields' => [ 'token' => 'public_key', ], 'continue' => true ] ]); Licensed under The MIT License For full copyright and license information, please see the LICENSE.txt
Наследование: extends Cake\Auth\BaseAuthenticate
Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( Cake\Controller\ComponentRegistry $registry, array $config ) Constructor.
authenticate ( Cake\Network\Request $request, Response $response ) : boolean Implemented because CakePHP forces you to.
getUser ( Cake\Network\Request $request ) : mixed Get token information from the request.
unauthenticated ( Cake\Network\Request $request, Response $response ) : boolean If unauthenticated, try to authenticate and respond.

Защищенные методы

Метод Описание
_findUser ( string $username, string $password = null ) : Mixed Find a user record.

Описание методов

__construct() публичный Метод

Settings for this object. - parameter The url parameter name of the token. - header The token header value. - userModel The model name of the User, defaults to Users. - fields The fields to use to identify a user by. Make sure 'token' has been added to the array - scope Additional conditions to use when looking up and authenticating users, i.e. ['Users.is_active' => 1]. - contain Extra models to contain. - continue Continue after trying token authentication or just throw the unauthorized exception. - unauthorized Exception name to throw or a status code as an integer.
public __construct ( Cake\Controller\ComponentRegistry $registry, array $config )
$registry Cake\Controller\ComponentRegistry The Component registry used on this request.
$config array Array of config to use.

_findUser() защищенный Метод

Find a user record.
protected _findUser ( string $username, string $password = null ) : Mixed
$username string The token identifier.
$password string Unused password.
Результат Mixed Either false on failure, or an array of user data.

authenticate() публичный Метод

Implemented because CakePHP forces you to.
public authenticate ( Cake\Network\Request $request, Response $response ) : boolean
$request Cake\Network\Request The request object.
$response Cake\Network\Response The response object.
Результат boolean Always false.

getUser() публичный Метод

Get token information from the request.
public getUser ( Cake\Network\Request $request ) : mixed
$request Cake\Network\Request Request object.
Результат mixed Either false or an array of user information

unauthenticated() публичный Метод

If unauthenticated, try to authenticate and respond.
public unauthenticated ( Cake\Network\Request $request, Response $response ) : boolean
$request Cake\Network\Request The request object.
$response Cake\Network\Response The response object.
Результат boolean False on failure, user on success.