You are here

public function AuthHelper::validateIdToken in Auth0 Single Sign On 8.2

Validate the ID token.

Parameters

string $idToken: The ID token to validate.

Return value

mixed A user array of named claims from the ID token.

Throws

CoreException

InvalidTokenException

\Exception

1 call to AuthHelper::validateIdToken()
AuthHelper::getUserUsingRefreshToken in src/Util/AuthHelper.php
Get the user using token.

File

src/Util/AuthHelper.php, line 116
Contains \Drupal\auth0\Util\AuthHelper.

Class

AuthHelper
Controller routines for auth0 authentication.

Namespace

Drupal\auth0\Util

Code

public function validateIdToken($idToken) {
  $auth0_domain = 'https://' . $this
    ->getAuthDomain() . '/';
  $auth0_settings = [];
  $auth0_settings['authorized_iss'] = [
    $auth0_domain,
  ];
  $auth0_settings['supported_algs'] = [
    $this->auth0JwtSignatureAlg,
  ];
  $auth0_settings['valid_audiences'] = [
    $this->clientId,
  ];
  $auth0_settings['client_secret'] = $this->clientSecret;
  $auth0_settings['secret_base64_encoded'] = $this->secretBase64Encoded;
  $jwt_verifier = new JWTVerifier($auth0_settings);
  return $jwt_verifier
    ->verifyAndDecode($idToken);
}