You are here

public function JWKFetcher::fetchKeys in Auth0 Single Sign On 8.2

Appends the default JWKS path to a token issuer to return all keys from a JWKS.

@codeCoverageIgnore

Parameters

string $iss:

Return value

array|mixed|null

Throws

\Exception

Deprecated

5.4.0, use requestJwkX5c instead.

File

vendor/auth0/auth0-php/src/Helpers/JWKFetcher.php, line 217

Class

JWKFetcher
Class JWKFetcher.

Namespace

Auth0\SDK\Helpers

Code

public function fetchKeys($iss) {
  $url = "{$iss}.well-known/jwks.json";
  if (($secret = $this->cache
    ->get($url)) === null) {
    $secret = [];
    $request = new RequestBuilder([
      'domain' => $iss,
      'basePath' => '.well-known/jwks.json',
      'method' => 'GET',
      'guzzleOptions' => $this->guzzleOptions,
    ]);
    $jwks = $request
      ->call();
    foreach ($jwks['keys'] as $key) {
      $secret[$key['kid']] = $this
        ->convertCertToPem($key['x5c'][0]);
    }
    $this->cache
      ->set($url, $secret);
  }
  return $secret;
}