class ClientRepository in Simple OAuth (OAuth2) & OpenID Connect 8.4
Same name and namespace in other branches
- 8.2 src/Repositories/ClientRepository.php \Drupal\simple_oauth\Repositories\ClientRepository
- 8.3 src/Repositories/ClientRepository.php \Drupal\simple_oauth\Repositories\ClientRepository
- 5.x src/Repositories/ClientRepository.php \Drupal\simple_oauth\Repositories\ClientRepository
Hierarchy
- class \Drupal\simple_oauth\Repositories\ClientRepository implements \League\OAuth2\Server\Repositories\ClientRepositoryInterface
Expanded class hierarchy of ClientRepository
1 string reference to 'ClientRepository'
1 service uses ClientRepository
File
- src/
Repositories/ ClientRepository.php, line 10
Namespace
Drupal\simple_oauth\RepositoriesView source
class ClientRepository implements ClientRepositoryInterface {
/**
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* @var \Drupal\Core\Password\PasswordInterface
*/
protected $passwordChecker;
/**
* Constructs a ClientRepository object.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, PasswordInterface $password_checker) {
$this->entityTypeManager = $entity_type_manager;
$this->passwordChecker = $password_checker;
}
/**
* {@inheritdoc}
*/
public function getClientEntity($client_identifier, $grant_type = NULL, $client_secret = NULL, $must_validate_secret = TRUE) {
$client_drupal_entities = $this->entityTypeManager
->getStorage('consumer')
->loadByProperties([
'uuid' => $client_identifier,
]);
// Check if the client is registered.
if (empty($client_drupal_entities)) {
return NULL;
}
/** @var \Drupal\consumers\Entity\Consumer $client_drupal_entity */
$client_drupal_entity = reset($client_drupal_entities);
$secret = $client_drupal_entity
->get('secret')->value;
if ($must_validate_secret && $client_drupal_entity
->get('confidential')->value && $this->passwordChecker
->check($client_secret, $secret) === FALSE) {
return NULL;
}
return new ClientEntity($client_drupal_entity);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ClientRepository:: |
protected | property | ||
ClientRepository:: |
protected | property | ||
ClientRepository:: |
public | function | ||
ClientRepository:: |
public | function | Constructs a ClientRepository object. |