Abstract password hashing class
Base Authentication class with common methods and properties.
Abstract base authorization adapter for AuthComponent.
Basic Authentication adapter for AuthComponent.
Provides Basic HTTP authentication support for AuthComponent. Basic Auth will authenticate users against the configured userModel and verify the username and passwords match.
Load AuthComponent in your controller's initialize() and add 'Basic' in 'authenticate' key
$this->loadComponent('Auth', [
'authenticate' => ['Basic']
'storage' => 'Memory',
'unauthorizedRedirect' => false,
]);
You should set storage to Memory to prevent CakePHP from sending a
session cookie to the client.
You should set unauthorizedRedirect to false. This causes AuthComponent to
throw a ForbiddenException exception instead of redirecting to another page.
Since HTTP Basic Authentication is stateless you don't need call setUser()
in your controller. The user credentials will be checked on each request. If
valid credentials are not provided, required authentication headers will be sent
by this authentication provider which triggers the login dialog in the browser/client.
An authorization adapter for AuthComponent. Provides the ability to authorize using a controller callback. Your controller's isAuthorized() method should return a boolean to indicate whether or not the user is authorized.
public function isAuthorized($user)
{
if ($this->request->getParam('admin')) {
return $user['role'] === 'admin';
}
return !empty($user);
}
The above is simple implementation that would only authorize users of the 'admin' role to access admin routing.
Default password hashing class.
Digest Authentication adapter for AuthComponent.
Provides Digest HTTP authentication support for AuthComponent.
Load AuthComponent in your controller's initialize() and add 'Digest' in 'authenticate' key
$this->loadComponent('Auth', [
'authenticate' => ['Digest'],
'storage' => 'Memory',
'unauthorizedRedirect' => false,
]);
You should set storage to Memory to prevent CakePHP from sending a
session cookie to the client.
You should set unauthorizedRedirect to false. This causes AuthComponent to
throw a ForbiddenException exception instead of redirecting to another page.
Since HTTP Digest Authentication is stateless you don't need call setUser()
in your controller. The user credentials will be checked on each request. If
valid credentials are not provided, required authentication headers will be sent
by this authentication provider which triggers the login dialog in the browser/client.
DigestAuthenticate requires a special password hash that conforms to RFC2617.
You can generate this password using DigestAuthenticate::password()
$digestPass = DigestAuthenticate::password($username, $password, env('SERVER_NAME'));
If you wish to use digest authentication alongside other authentication methods,
it's recommended that you store the digest authentication separately. For
example User.digest_pass could be used for a digest password, while
User.password would store the password hash for use with other methods like
Basic or Form.
A password hasher that can use multiple different hashes where only one is the preferred one. This is useful when trying to migrate an existing database of users from one password type to another.
Form authentication adapter for AuthComponent.
Allows you to authenticate users based on form POST data. Usually, this is a login form that users enter information into.
Load AuthComponent in your controller's initialize() and add 'Form' in 'authenticate' key
$this->loadComponent('Auth', [
'authenticate' => [
'Form' => [
'fields' => ['username' => 'email', 'password' => 'passwd'],
'finder' => 'auth',
]
]
]);
When configuring FormAuthenticate you can pass in config to which fields, model and finder
are used. See BaseAuthenticate::$_defaultConfig for more information.
Builds password hashing objects
Password hashing class that use weak hashing algorithms. This class is intended only to be used with legacy databases where passwords have not been migrated to a stronger algorithm yet.