You are here

interface ExternalAuthInterface in External Authentication 2.0.x

Same name and namespace in other branches
  1. 8 src/ExternalAuthInterface.php \Drupal\externalauth\ExternalAuthInterface

Interface ExternalAuthInterface.

@package Drupal\externalauth

Hierarchy

Expanded class hierarchy of ExternalAuthInterface

All classes that implement ExternalAuthInterface

File

src/ExternalAuthInterface.php, line 12

Namespace

Drupal\externalauth
View source
interface ExternalAuthInterface {

  /**
   * Load a Drupal user based on an external authname.
   *
   * D7 equivalent: user_external_load().
   *
   * @param string $authname
   *   The unique, external authentication name provided by authentication
   *   provider.
   * @param string $provider
   *   The module providing external authentication.
   *
   * @return \Drupal\user\UserInterface
   *   The loaded Drupal user.
   */
  public function load($authname, $provider);

  /**
   * Log a Drupal user in based on an external authname.
   *
   * @param string $authname
   *   The unique, external authentication name provided by authentication
   *   provider.
   * @param string $provider
   *   The module providing external authentication.
   *
   * @return \Drupal\user\UserInterface|bool
   *   The logged in Drupal user.
   */
  public function login($authname, $provider);

  /**
   * Register a Drupal user based on an external authname.
   *
   * The Drupal username of the account to be created defaults to the external
   * authentication name prefixed with the provider ID. The caller may enforce
   * a custom Drupal username by setting that value in $account_data['name'].
   *
   * @param string $authname
   *   The unique, external authentication name provided by authentication
   *   provider.
   * @param string $provider
   *   The module providing external authentication.
   * @param array $account_data
   *   An array of additional properties to be saved with the user entity. If
   *   the array contains a 'name' string value, it will be used as local Drupal
   *   username, otherwise a default local Drupal username will be computed as
   *   "{$provider}_{$authname}".
   * @param mixed $authmap_data
   *   Additional data to be stored in the authmap entry.
   *
   * @return \Drupal\user\UserInterface
   *   The registered Drupal user.
   */
  public function register($authname, $provider, array $account_data = [], $authmap_data = NULL);

  /**
   * Login and optionally register a Drupal user based on an external authname.
   *
   * @param string $authname
   *   The unique, external authentication name provided by authentication
   *   provider.
   * @param string $provider
   *   The module providing external authentication.
   * @param array $account_data
   *   An array of additional properties to be saved with the user entity.
   * @param mixed $authmap_data
   *   Additional data to be stored in the authmap entry.
   *
   * @return \Drupal\user\UserInterface
   *   The logged in, and optionally registered, Drupal user.
   */
  public function loginRegister($authname, $provider, array $account_data = [], $authmap_data = NULL);

  /**
   * Finalize logging in the external user.
   *
   * Encapsulates user_login_finalize.
   *
   * @param \Drupal\user\UserInterface $account
   *   The Drupal user to finalize login for.
   * @param string $authname
   *   The unique, external authentication name provided by authentication
   *   provider.
   * @param string $provider
   *   The module providing external authentication.
   *
   * @return \Drupal\user\UserInterface
   *   The logged in Drupal user.
   *
   * @codeCoverageIgnore
   */
  public function userLoginFinalize(UserInterface $account, $authname, $provider);

  /**
   * Link a pre-existing Drupal user to a given authname.
   *
   * @param string $authname
   *   The unique, external authentication name provided by authentication
   *   provider.
   * @param string $provider
   *   The module providing external authentication.
   * @param \Drupal\user\UserInterface $account
   *   The existing Drupal account to link.
   */
  public function linkExistingAccount($authname, $provider, UserInterface $account);

}

Members

Namesort descending Modifiers Type Description Overrides
ExternalAuthInterface::linkExistingAccount public function Link a pre-existing Drupal user to a given authname. 1
ExternalAuthInterface::load public function Load a Drupal user based on an external authname. 1
ExternalAuthInterface::login public function Log a Drupal user in based on an external authname. 1
ExternalAuthInterface::loginRegister public function Login and optionally register a Drupal user based on an external authname. 1
ExternalAuthInterface::register public function Register a Drupal user based on an external authname. 1
ExternalAuthInterface::userLoginFinalize public function Finalize logging in the external user. 1