Yoast\WP\SEO\MyYoast_Client\Application

Authorization_Code_Handler::validate_id_token_nonce │ private │ Yoast 1.0

Validates the nonce claim in the ID token against the stored nonce.

Метод класса: Authorization_Code_Handler{}

Хуков нет.

Возвращает

void. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->validate_id_token_nonce( $token_set, $flow_state ): void;
$token_set(Token_Set) (обязательный)
The token set containing the ID token.
$flow_state(Auth_Flow_State) (обязательный)
The flow state containing the expected nonce.

Код Authorization_Code_Handler::validate_id_token_nonce() Yoast 28.9

private function validate_id_token_nonce( Token_Set $token_set, Auth_Flow_State $flow_state ): void {
	$id_token = $token_set->get_id_token();
	if ( $id_token === null ) {
		return;
	}

	$nonce = $flow_state->get_nonce();
	if ( $nonce === null ) {
		// No nonce was sent (openid scope not requested), skip ID token nonce validation.
		return;
	}

	$registered_client = $this->client_registration->get_registered_client();
	if ( $registered_client === null ) {
		throw new Token_Request_Failed_Exception( 'client_not_registered', 'Client registration not found during ID token validation.' );
	}

	try {
		$this->id_token_validator->validate( $id_token, $registered_client->get_client_id(), $nonce );
	} catch ( ID_Token_Validation_Exception $e ) {
		// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
		throw new Token_Request_Failed_Exception( 'invalid_id_token', $e->getMessage(), 0, $e );
	} catch ( Discovery_Failed_Exception | Server_Capability_Exception $e ) {
		// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
		throw new Token_Request_Failed_Exception( 'discovery_failed', $e->getMessage(), 0, $e );
	}
}