You are here

class OpenIDConnectStateToken in OpenID Connect / OAuth client 8

Same name and namespace in other branches
  1. 2.x src/OpenIDConnectStateToken.php \Drupal\openid_connect\OpenIDConnectStateToken

Creates and validates state tokens.

@package Drupal\openid_connect

Hierarchy

Expanded class hierarchy of OpenIDConnectStateToken

1 file declares its use of OpenIDConnectStateToken
OpenIDConnectStateTokenTest.php in tests/src/Unit/OpenIDConnectStateTokenTest.php
1 string reference to 'OpenIDConnectStateToken'
openid_connect.services.yml in ./openid_connect.services.yml
openid_connect.services.yml
1 service uses OpenIDConnectStateToken
openid_connect.state_token in ./openid_connect.services.yml
Drupal\openid_connect\OpenIDConnectStateToken

File

src/OpenIDConnectStateToken.php, line 12

Namespace

Drupal\openid_connect
View source
class OpenIDConnectStateToken implements OpenIDConnectStateTokenInterface {

  /**
   * {@inheritdoc}
   */
  public static function create() {
    $state = Crypt::randomBytesBase64();
    $_SESSION['openid_connect_state'] = $state;
    return $state;
  }

  /**
   * {@inheritdoc}
   */
  public static function confirm($state_token) {
    return isset($_SESSION['openid_connect_state']) && $state_token == $_SESSION['openid_connect_state'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OpenIDConnectStateToken::confirm public static function Confirms anti-forgery state token. Overrides OpenIDConnectStateTokenInterface::confirm
OpenIDConnectStateToken::create public static function Creates a state token and stores it in the session for later validation. Overrides OpenIDConnectStateTokenInterface::create