Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_API_Authentication::perform_oauth_authentication()
Perform OAuth 1.0a “one-legged” (http://oauthbible.com/#oauth-10a-one-legged) authentication for non-SSL requests
Description Description
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
Return Return
(array)
Source Source
File: includes/legacy/api/v2/class-wc-api-authentication.php
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; }
Changelog Changelog
Version | Description |
---|---|
2.1 | Introduced. |