← All changes
|
jetpack_vendor/automattic/jetpack-connection/src/class-rest-authentication.php
+16
-0
13.7.2
→
16.3-beta
View file →
| @@ -118,8 +118,11 @@ | ||
| 118 | 118 | // Nothing to do for this authentication method. |
| 119 | 119 | return null; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | + // These `rest_invalid_request` errors occur before `verify_xml_rpc_signature()`, | |
| 123 | + // so the request has not been authenticated as WP.com. Do not report them to | |
| 124 | + // Error_Handler: they are malformed unauthenticated requests, not connection errors. | |
| 122 | 125 | if ( ! isset( $_SERVER['REQUEST_METHOD'] ) ) { |
| 123 | 126 | $this->rest_authentication_status = new WP_Error( |
| 124 | 127 | 'rest_invalid_request', |
| 125 | 128 | __( 'The request method is missing.', 'jetpack-connection' ), |
| @@ -217,6 +220,19 @@ | ||
| 217 | 220 | public static function is_signed_with_blog_token() { |
| 218 | 221 | $instance = self::init(); |
| 219 | 222 | |
| 220 | 223 | return true === $instance->rest_authentication_status && 'blog' === $instance->rest_authentication_type; |
| 224 | + } | |
| 225 | + | |
| 226 | + /** | |
| 227 | + * Whether the request was signed with a user token. | |
| 228 | + * | |
| 229 | + * @since 6.7.0 | |
| 230 | + * | |
| 231 | + * @return bool True if the request was signed with a valid user token, false otherwise. | |
| 232 | + */ | |
| 233 | + public static function is_signed_with_user_token() { | |
| 234 | + $instance = self::init(); | |
| 235 | + | |
| 236 | + return true === $instance->rest_authentication_status && 'user' === $instance->rest_authentication_type; | |
| 221 | 237 | } |
| 222 | 238 | } |