WC_API_Authentication::perform_oauth_authentication()privateWC 2.1

Perform OAuth 1.0a "one-legged" (http://oauthbible.com/#oauth-10a-one-legged) authentication for non-SSL requests

This is required so API credentials cannot be sniffed or intercepted when making API requests over plain HTTP

This follows the spec for simple OAuth 1.0a authentication (RFC 5849) as closely as possible, with two exceptions:

1) There is no token associated with request/responses, only consumer keys/secrets are used

2) The OAuth parameters are included as part of the request query string instead of part of the Authorization header,

This is because there is no cross-OS function within PHP to get the raw Authorization header

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

Хуков нет.

Возвращает

Массив.

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

// private - только в коде основоного (родительского) класса
$result = $this->perform_oauth_authentication();

Список изменений

С версии 2.1 Введена.

Код WC_API_Authentication::perform_oauth_authentication() WC 8.7.0

private function perform_oauth_authentication() {

	$params = WC()->api->server->params['GET'];

	$param_names = array( 'oauth_consumer_key', 'oauth_timestamp', 'oauth_nonce', 'oauth_signature', 'oauth_signature_method' );

	// Check for required OAuth parameters
	foreach ( $param_names as $param_name ) {

		if ( empty( $params[ $param_name ] ) ) {
			throw new Exception( sprintf( __( '%s parameter is missing', 'woocommerce' ), $param_name ), 404 );
		}
	}

	// Fetch WP user by consumer key
	$keys = $this->get_keys_by_consumer_key( $params['oauth_consumer_key'] );

	// Perform OAuth validation
	$this->check_oauth_signature( $keys, $params );
	$this->check_oauth_timestamp_and_nonce( $keys, $params['oauth_timestamp'], $params['oauth_nonce'] );

	// Authentication successful, return user
	return $keys;
}