You are here

class SessionStateHandler in Auth0 Single Sign On 8.2

Session based implementation of StateHandler.

@author Auth0

Hierarchy

Expanded class hierarchy of SessionStateHandler

Deprecated

5.7.0, replaced by Auth0\SDK\Helpers\TransientStoreHandler

3 files declare their use of SessionStateHandler
Auth0.php in vendor/auth0/auth0-php/src/Auth0.php
AuthController.php in src/Controller/AuthController.php
Contains \Drupal\auth0\Controller\AuthController.
SessionStateHandlerTest.php in vendor/auth0/auth0-php/tests/API/Helpers/State/SessionStateHandlerTest.php

File

vendor/auth0/auth0-php/src/API/Helpers/State/SessionStateHandler.php, line 23

Namespace

Auth0\SDK\API\Helpers\State
View source
class SessionStateHandler implements StateHandler {
  const STATE_NAME = 'webauth_state';
  private $store;

  /**
   *
   * @param StoreInterface $store
   */
  public function __construct(StoreInterface $store) {
    $this->store = $store;
  }

  /**
   * Generate state value to be used for the state param value during authorization.
   *
   * @return string
   */
  public function issue() {
    $state = uniqid('', true);
    $this
      ->store($state);
    return $state;
  }

  /**
   * Store a given state value to be used for the state param value during authorization.
   *
   * @param string $state
   *
   * @return mixed|void
   */
  public function store($state) {
    $this->store
      ->set(self::STATE_NAME, $state);
  }

  /**
   * Perform validation of the returned state with the previously generated state.
   *
   * @param string $state
   *
   * @return boolean
   */
  public function validate($state) {
    $valid = $this->store
      ->get(self::STATE_NAME) == $state;
    $this->store
      ->delete(self::STATE_NAME);
    return $valid;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SessionStateHandler::$store private property
SessionStateHandler::issue public function Generate state value to be used for the state param value during authorization. Overrides StateHandler::issue
SessionStateHandler::STATE_NAME constant
SessionStateHandler::store public function Store a given state value to be used for the state param value during authorization. Overrides StateHandler::store
SessionStateHandler::validate public function Perform validation of the returned state with the previously generated state. Overrides StateHandler::validate
SessionStateHandler::__construct public function