You are here

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

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

Plugin annotation


@Oauth2Grant(
  id = "password",
  label = @Translation("Password")
)

Hierarchy

Expanded class hierarchy of Password

File

src/Plugin/Oauth2Grant/Password.php, line 18

Namespace

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

  /**
   * @var \League\OAuth2\Server\Repositories\UserRepositoryInterface
   */
  protected $userRepository;

  /**
   * @var \League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface
   */
  protected $refreshTokenRepository;

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Class constructor.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, UserRepositoryInterface $user_repository, RefreshTokenRepositoryInterface $refresh_token_repository, ConfigFactoryInterface $config_factory) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->userRepository = $user_repository;
    $this->refreshTokenRepository = $refresh_token_repository;
    $this->configFactory = $config_factory;
  }

  /**
   * {@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.user'), $container
      ->get('simple_oauth.repositories.refresh_token'), $container
      ->get('config.factory'));
  }

  /**
   * {@inheritdoc}
   */
  public function getGrantType() {
    $grant = new PasswordGrant($this->userRepository, $this->refreshTokenRepository);
    $settings = $this->configFactory
      ->get('simple_oauth.settings');
    $grant
      ->setRefreshTokenTTL(new \DateInterval(sprintf('PT%dS', $settings
      ->get('refresh_token_expiration'))));
    return $grant;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Password::$configFactory protected property The config factory.
Password::$refreshTokenRepository protected property
Password::$userRepository protected property
Password::create public static function Creates an instance of the plugin. Overrides Oauth2GrantBase::create
Password::getGrantType public function Gets the grant object. Overrides Oauth2GrantInterface::getGrantType
Password::__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.