You are here

protected function AuthController::getNonce in Auth0 Single Sign On 8.2

Same name and namespace in other branches
  1. 8 src/Controller/AuthController.php \Drupal\auth0\Controller\AuthController::getNonce()

Create a new nonce in session and return it.

Parameters

string $returnTo: The return url.

Return value

string The nonce string.

2 calls to AuthController::getNonce()
AuthController::buildAuthorizeUrl in src/Controller/AuthController.php
Build the Authorize url.
AuthController::login in src/Controller/AuthController.php
Handles the login page override.

File

src/Controller/AuthController.php, line 318
Contains \Drupal\auth0\Controller\AuthController.

Class

AuthController
Controller routines for auth0 authentication.

Namespace

Drupal\auth0\Controller

Code

protected function getNonce($returnTo) {

  // Have to start the session after putting something into the session, or
  // we don't actually start it!
  if (!$this->sessionManager
    ->isStarted() && !isset($_SESSION['auth0_is_session_started'])) {
    $_SESSION['auth0_is_session_started'] = 'yes';
    $this->sessionManager
      ->regenerate();
  }
  $sessionStateHandler = new SessionStateHandler(new SessionStore());
  $states = $this->tempStore
    ->get(AuthController::STATE);
  if (!is_array($states)) {
    $states = [];
  }
  $nonce = $sessionStateHandler
    ->issue();
  $states[$nonce] = $returnTo === NULL ? '' : $returnTo;
  $this->tempStore
    ->set(AuthController::STATE, $states);
  return $nonce;
}