File: //wordpress/plugins/wp-cloud-client/1.1.5/src/Auth/AuthMiddleware.php
<?php
declare(strict_types=1);
namespace VPlugins\WPCloudClient\Auth;
use WP_Error;
use WP_REST_Request;
final readonly class AuthMiddleware {
/**
* Construct the authentication middleware.
*
* @param ApiKeyAuthenticator $authenticator API key authenticator instance.
*/
public function __construct(
private ApiKeyAuthenticator $authenticator,
) {}
/**
* Check whether the incoming request passes authentication.
*
* @param WP_REST_Request $request The incoming REST request.
* @return true|WP_Error True if authenticated, WP_Error on failure.
*/
public function check( WP_REST_Request $request ): true|WP_Error {
return $this->authenticator->validate( $request );
}
}