You are here

class AccessTokenRepository in Simple OAuth (OAuth2) & OpenID Connect 8.4

Same name and namespace in other branches
  1. 8.2 src/Repositories/AccessTokenRepository.php \Drupal\simple_oauth\Repositories\AccessTokenRepository
  2. 8.3 src/Repositories/AccessTokenRepository.php \Drupal\simple_oauth\Repositories\AccessTokenRepository
  3. 5.x src/Repositories/AccessTokenRepository.php \Drupal\simple_oauth\Repositories\AccessTokenRepository

The access token repository.

Hierarchy

Expanded class hierarchy of AccessTokenRepository

1 string reference to 'AccessTokenRepository'
simple_oauth.services.yml in ./simple_oauth.services.yml
simple_oauth.services.yml
1 service uses AccessTokenRepository
simple_oauth.repositories.access_token in ./simple_oauth.services.yml
Drupal\simple_oauth\Repositories\AccessTokenRepository

File

src/Repositories/AccessTokenRepository.php, line 13

Namespace

Drupal\simple_oauth\Repositories
View source
class AccessTokenRepository implements AccessTokenRepositoryInterface {
  use RevocableTokenRepositoryTrait;

  /**
   * The bundle ID.
   *
   * @var string
   */
  protected static $bundleId = 'access_token';

  /**
   * The OAuth2 entity class name.
   *
   * @var string
   */
  protected static $entityClass = 'Drupal\\simple_oauth\\Entities\\AccessTokenEntity';

  /**
   * The OAuth2 entity interface name.
   *
   * @var string
   */
  protected static $entityInterface = 'League\\OAuth2\\Server\\Entities\\AccessTokenEntityInterface';

  /**
   * {@inheritdoc}
   */
  public function persistNewAccessToken(AccessTokenEntityInterface $access_token_entity) {
    $this
      ->persistNew($access_token_entity);
  }

  /**
   * {@inheritdoc}
   */
  public function revokeAccessToken($token_id) {
    $this
      ->revoke($token_id);
  }

  /**
   * {@inheritdoc}
   */
  public function isAccessTokenRevoked($token_id) {
    return $this
      ->isRevoked($token_id);
  }

  /**
   * {@inheritdoc}
   */
  public function getNewToken(ClientEntityInterface $client_entity, array $scopes, $user_identifier = NULL) {
    $access_token = new AccessTokenEntity();
    $access_token
      ->setClient($client_entity);
    foreach ($scopes as $scope) {
      $access_token
        ->addScope($scope);
    }
    $access_token
      ->setUserIdentifier($user_identifier);
    return $access_token;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AccessTokenRepository::$bundleId protected static property The bundle ID.
AccessTokenRepository::$entityClass protected static property The OAuth2 entity class name.
AccessTokenRepository::$entityInterface protected static property The OAuth2 entity interface name.
AccessTokenRepository::getNewToken public function
AccessTokenRepository::isAccessTokenRevoked public function
AccessTokenRepository::persistNewAccessToken public function
AccessTokenRepository::revokeAccessToken public function
RevocableTokenRepositoryTrait::$entityTypeId protected static property The entity type ID.
RevocableTokenRepositoryTrait::$entityTypeManager protected property The entity type manager.
RevocableTokenRepositoryTrait::$serializer protected property The serializer.
RevocableTokenRepositoryTrait::getNew public function
RevocableTokenRepositoryTrait::isRevoked public function
RevocableTokenRepositoryTrait::persistNew public function
RevocableTokenRepositoryTrait::revoke public function
RevocableTokenRepositoryTrait::__construct public function Construct a revocable token.