This little plugin provides an Authenticate adapter for stateless Authentication. It allows you to specify a special header, which contains a token to authorize in your application. This can be very helpful for testing, be it unittests or manual tests with API clients (like Postman) or directly in your client software.
composer require gringlas/cakephp-ep-authenticate dev-master
Just add gringlas/EPAuthenticate.EP
to your AuthComponent authenticate, like
$this->loacComponent('Auth', [
'authenticate' => [
'gringlas/EPAuthenticate.EP' => [
'header' => 'EP-Authorization',
'userId' => 1,
'debugOnly' => false,
'password' => 'EPme',
],
...
);
Send add set header
and password
to your next request and get authenticated as User with id userid
.
userId
: Id of User data, which should be authed, defaults to 1debugOnly
: only use AuthenticateAdapter whenenv('debug', true)
, defaults to trueheader
: Name of header, defaults toEP-Authorization
password
: Value of header, defaults toEPme
- Add custom UserModel, so far only users from DB table are supported
- Add custom finder method, so far only a
$this->User->get($this->getConfig['user'])
is used to get User data.