Yoast\WP\SEO\MyYoast_Client\Infrastructure\OIDC
ID_Token_Validator::fetch_jwks
Fetches the JWKS from the server (cached).
Метод класса: ID_Token_Validator{}
Хуков нет.
Возвращает
Массив<Строку,. array<int, array<string, string>>>|null The JWKS, or null on failure.
Использование
// private - только в коде основоного (родительского) класса $result = $this->fetch_jwks(): ?array;
Код ID_Token_Validator::fetch_jwks() ID Token Validator::fetch jwks Yoast 27.7
private function fetch_jwks(): ?array {
$cached = \get_transient( $this->get_jwks_transient_key() );
if ( \is_array( $cached ) && ! empty( $cached['keys'] ) ) {
return $cached;
}
try {
$jwks_uri = $this->discovery_client->get_document()->get_jwks_uri();
} catch ( Discovery_Failed_Exception | Server_Capability_Exception $e ) {
$this->logger->warning( 'Cannot fetch JWKS: discovery failed: {error}', [ 'error' => $e->getMessage() ] );
return null;
}
$result = $this->http_client->request(
'GET',
$jwks_uri,
[
'timeout' => 10,
'headers' => [ 'Accept' => 'application/json' ],
],
);
if ( $result->get_status() !== 200 ) {
$this->logger->warning(
'JWKS fetch returned HTTP {status} from {url}.',
[
'status' => $result->get_status(),
'url' => $jwks_uri,
],
);
return null;
}
$body = $result->get_body();
if ( ! \is_array( $body ) || empty( $body['keys'] ) ) {
$this->logger->warning( 'JWKS response from {url} has no keys.', [ 'url' => $jwks_uri ] );
return null;
}
\set_transient( $this->get_jwks_transient_key(), $body, self::JWKS_TTL );
return $body;
}