You are here

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

Same name and namespace in other branches
  1. 5.x src/Plugin/Oauth2Grant/AuthorizationCode.php \Drupal\simple_oauth\Plugin\Oauth2Grant\AuthorizationCode

The authorization code grant plugin.

Plugin annotation


@Oauth2Grant(
  id = "authorization_code",
  label = @Translation("Authorization Code")
)

Hierarchy

Expanded class hierarchy of AuthorizationCode

File

src/Plugin/Oauth2Grant/AuthorizationCode.php, line 20

Namespace

Drupal\simple_oauth\Plugin\Oauth2Grant
View source
class AuthorizationCode extends Oauth2GrantBase {

  /**
   * The authorization code repository.
   *
   * @var \League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface
   */
  protected $authCodeRepository;

  /**
   * The refresh token repository.
   *
   * @var \League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface
   */
  protected $refreshTokenRepository;

  /**
   * The expiration for the code.
   *
   * @var \DateTime
   */
  protected $authCodeExpiration;

  /**
   * Class constructor.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, AuthCodeRepositoryInterface $auth_code_repository, RefreshTokenRepositoryInterface $refresh_token_repository, ConfigFactoryInterface $config_factory) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $settings = $config_factory
      ->get('simple_oauth.settings');
    $this->authCodeRepository = $auth_code_repository;
    $this->refreshTokenRepository = $refresh_token_repository;
    $this->authCodeExpiration = new \DateInterval(sprintf('PT%dS', $settings
      ->get('authorization_code_expiration')));
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('simple_oauth.repositories.auth_code'), $container
      ->get('simple_oauth.repositories.refresh_token'), $container
      ->get('config.factory'));
  }

  /**
   * {@inheritdoc}
   */
  public function getGrantType() {
    return new AuthCodeGrant($this->authCodeRepository, $this->refreshTokenRepository, $this->authCodeExpiration);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AuthorizationCode::$authCodeExpiration protected property The expiration for the code.
AuthorizationCode::$authCodeRepository protected property The authorization code repository.
AuthorizationCode::$refreshTokenRepository protected property The refresh token repository.
AuthorizationCode::create public static function Creates an instance of the plugin. Overrides Oauth2GrantBase::create
AuthorizationCode::getGrantType public function Gets the grant object. Overrides Oauth2GrantInterface::getGrantType
AuthorizationCode::__construct public function Class constructor. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.