public function SimpleOauthAuthenticationProvider::authenticate in Simple OAuth (OAuth2) & OpenID Connect 8
Same name and namespace in other branches
- 8.4 src/Authentication/Provider/SimpleOauthAuthenticationProvider.php \Drupal\simple_oauth\Authentication\Provider\SimpleOauthAuthenticationProvider::authenticate()
- 8.2 src/Authentication/Provider/SimpleOauthAuthenticationProvider.php \Drupal\simple_oauth\Authentication\Provider\SimpleOauthAuthenticationProvider::authenticate()
- 8.3 src/Authentication/Provider/SimpleOauthAuthenticationProvider.php \Drupal\simple_oauth\Authentication\Provider\SimpleOauthAuthenticationProvider::authenticate()
- 5.x src/Authentication/Provider/SimpleOauthAuthenticationProvider.php \Drupal\simple_oauth\Authentication\Provider\SimpleOauthAuthenticationProvider::authenticate()
Authenticates the user.
Parameters
\Symfony\Component\HttpFoundation\Request|null $request: The request object.
Return value
\Drupal\Core\Session\AccountInterface|null AccountInterface - in case of a successful authentication. NULL - in case where authentication failed.
Overrides AuthenticationProviderInterface::authenticate
File
- src/
Authentication/ Provider/ SimpleOauthAuthenticationProvider.php, line 83
Class
- SimpleOauthAuthenticationProvider
- Class SimpleOauthAuthenticationProvider.
Namespace
Drupal\simple_oauth\Authentication\ProviderCode
public function authenticate(Request $request) {
$token_storage = $this->entityManager
->getStorage('access_token');
$ids = $token_storage
->getQuery()
->condition('value', $this::getTokenValue($request))
->condition('expire', REQUEST_TIME, '>')
->range(0, 1)
->execute();
if (!empty($ids)) {
/* @var \Drupal\simple_oauth\AccessTokenInterface $token */
$token = $token_storage
->load(reset($ids));
try {
return new TokenAuthUser($token);
} catch (\Exception $e) {
}
}
return [];
}