You are here

private function JWKFetcher::findJwk in Auth0 Single Sign On 8.2

Get a JWK from a JWKS using a key ID, if provided.

@codeCoverageIgnore

Parameters

array $jwks JWKS to parse.:

null|string $kid Key ID to return; returns first JWK if $kid is null or empty.:

Return value

array|null Null if the keys array is empty or if the key ID is not found.

Deprecated

5.6.0, use $this->getKeys().

1 call to JWKFetcher::findJwk()
JWKFetcher::requestJwkX5c in vendor/auth0/auth0-php/src/Helpers/JWKFetcher.php
Fetch x509 cert for RS256 token decoding.

File

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

Class

JWKFetcher
Class JWKFetcher.

Namespace

Auth0\SDK\Helpers

Code

private function findJwk(array $jwks, $kid = null) {
  if ($this
    ->subArrayHasEmptyFirstItem($jwks, 'keys')) {
    return null;
  }
  if (!$kid) {
    return $jwks['keys'][0];
  }
  foreach ($jwks['keys'] as $key) {
    if (isset($key['kid']) && $key['kid'] === $kid) {
      return $key;
    }
  }
  return null;
}