class KeyAuth in Key auth 8
Same name in this branch
- 8 src/KeyAuth.php \Drupal\key_auth\KeyAuth
- 8 src/Authentication/Provider/KeyAuth.php \Drupal\key_auth\Authentication\Provider\KeyAuth
Key authentication provider.
Hierarchy
- class \Drupal\key_auth\Authentication\Provider\KeyAuth implements AuthenticationProviderInterface
Expanded class hierarchy of KeyAuth
1 string reference to 'KeyAuth'
1 service uses KeyAuth
File
- src/
Authentication/ Provider/ KeyAuth.php, line 12
Namespace
Drupal\key_auth\Authentication\ProviderView source
class KeyAuth implements AuthenticationProviderInterface {
/**
* The key auth service.
*
* @var \Drupal\key_auth\KeyAuthInterface
*/
protected $keyAuth;
/**
* Constructs a key authentication provider object.
*
* @param \Drupal\key_auth\KeyAuthInterface $key_auth
* The key auth service.
*/
public function __construct(KeyAuthInterface $key_auth) {
$this->keyAuth = $key_auth;
}
/**
* {@inheritdoc}
*/
public function applies(Request $request) {
return (bool) $this->keyAuth
->getKey($request);
}
/**
* {@inheritdoc}
*/
public function authenticate(Request $request) {
// Get the provided key.
if ($key = $this->keyAuth
->getKey($request)) {
// Find the linked user.
if ($user = $this->keyAuth
->getUserByKey($key)) {
// Check access.
if ($this->keyAuth
->access($user)) {
// Return the user.
return $user;
}
}
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
KeyAuth:: |
protected | property | The key auth service. | |
KeyAuth:: |
public | function |
Checks whether suitable authentication credentials are on the request. Overrides AuthenticationProviderInterface:: |
|
KeyAuth:: |
public | function |
Authenticates the user. Overrides AuthenticationProviderInterface:: |
|
KeyAuth:: |
public | function | Constructs a key authentication provider object. |