Skip to content

Commit

Permalink
Jetpack Connection - REST API: Allow site-level authentication on POS…
Browse files Browse the repository at this point in the history
…T requests to 'jetpack/v4/connection' (#39503)

* Jetpack Connection: Allow blog token when disconnecting via REST API

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11013818112

Upstream-Ref: Automattic/jetpack@beb5ea5
  • Loading branch information
fgiannar authored and matticbot committed Sep 24, 2024
1 parent e525191 commit f2dac22
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 136 deletions.
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-backup/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"automattic/jetpack-backup-helper-script-manager": "^0.2.7",
"automattic/jetpack-composer-plugin": "^2.0.3",
"automattic/jetpack-config": "^2.0.4",
"automattic/jetpack-connection": "^5.0.0",
"automattic/jetpack-connection": "^5.1.0-alpha",
"automattic/jetpack-my-jetpack": "^4.35.7",
"automattic/jetpack-sync": "^3.13.1",
"automattic/jetpack-status": "^4.0.2"
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-boost-core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"automattic/jetpack-connection": "^5.0.0"
"automattic/jetpack-connection": "^5.1.0-alpha"
},
"require-dev": {
"yoast/phpunit-polyfills": "^1.1.1",
Expand Down
8 changes: 8 additions & 0 deletions jetpack_vendor/automattic/jetpack-connection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.1.0-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Changed
- Jetpack Connection - REST API: Allow site-level authentication on POST requests to 'jetpack/v4/connection'

## [5.0.0] - 2024-09-23
### Removed
- Connection: Removed deprecated features_enabled method [#39475]
Expand Down Expand Up @@ -1207,6 +1214,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Separate the connection library into its own package.

[5.1.0-alpha]: https://github.com/Automattic/jetpack-connection/compare/v5.0.0...v5.1.0-alpha
[5.0.0]: https://github.com/Automattic/jetpack-connection/compare/v4.0.4...v5.0.0
[4.0.4]: https://github.com/Automattic/jetpack-connection/compare/v4.0.3...v4.0.4
[4.0.3]: https://github.com/Automattic/jetpack-connection/compare/v4.0.2...v4.0.3
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-connection/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"link-template": "https://github.com/Automattic/jetpack-connection/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "5.0.x-dev"
"dev-trunk": "5.1.x-dev"
},
"dependencies": {
"test-only": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class Package_Version {

const PACKAGE_VERSION = '5.0.0';
const PACKAGE_VERSION = '5.1.0-alpha';

const PACKAGE_SLUG = 'connection';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,18 +545,18 @@ public static function connection_plugins_permission_check() {
*
* @since 1.30.1
*
* @return bool|WP_Error True if user is able to disconnect the site.
* @since 5.1.0-alpha Modified the permission check to accept requests signed with blog tokens.
*
* @return bool|WP_Error True if user is able to disconnect the site or the request is signed with a blog token (aka a direct request from WPCOM).
*/
public static function disconnect_site_permission_check() {
if ( current_user_can( 'jetpack_disconnect' ) ) {
return true;
}

return new WP_Error(
'invalid_user_permission_jetpack_disconnect',
self::get_user_permissions_error_msg(),
array( 'status' => rest_authorization_required_code() )
);
return Rest_Authentication::is_signed_with_blog_token()
? true
: new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::get_user_permissions_error_msg(), array( 'status' => rest_authorization_required_code() ) );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-explat/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"automattic/jetpack-connection": "^5.0.0"
"automattic/jetpack-connection": "^5.1.0-alpha"
},
"require-dev": {
"yoast/phpunit-polyfills": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-jitm/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"php": ">=7.0",
"automattic/jetpack-a8c-mc-stats": "^2.0.2",
"automattic/jetpack-assets": "^2.3.8",
"automattic/jetpack-connection": "^5.0.0",
"automattic/jetpack-connection": "^5.1.0-alpha",
"automattic/jetpack-device-detection": "^2.1.5",
"automattic/jetpack-logo": "^2.0.4",
"automattic/jetpack-redirect": "^2.0.4",
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-licensing/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"automattic/jetpack-connection": "^5.0.0"
"automattic/jetpack-connection": "^5.1.0-alpha"
},
"require-dev": {
"automattic/wordbless": "@dev",
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-my-jetpack/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"automattic/jetpack-admin-ui": "^0.4.5",
"automattic/jetpack-assets": "^2.3.8",
"automattic/jetpack-boost-speed-score": "^0.3.12",
"automattic/jetpack-connection": "^5.0.0",
"automattic/jetpack-connection": "^5.1.0-alpha",
"automattic/jetpack-explat": "^0.1.9",
"automattic/jetpack-jitm": "^3.1.23",
"automattic/jetpack-licensing": "^2.0.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"automattic/jetpack-connection": "^5.0.0",
"automattic/jetpack-connection": "^5.1.0-alpha",
"automattic/jetpack-plugins-installer": "^0.4.3",
"automattic/jetpack-sync": "^3.13.1",
"automattic/jetpack-protect-models": "^0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-sync/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"automattic/jetpack-connection": "^5.0.0",
"automattic/jetpack-connection": "^5.1.0-alpha",
"automattic/jetpack-constants": "^2.0.4",
"automattic/jetpack-password-checker": "^0.3.2",
"automattic/jetpack-ip": "^0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/i18n-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
),
'jetpack-connection' => array(
'path' => 'jetpack_vendor/automattic/jetpack-connection',
'ver' => '5.0.0',
'ver' => '5.1.0-alpha1727181107',
),
'jetpack-explat' => array(
'path' => 'jetpack_vendor/automattic/jetpack-explat',
Expand Down
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-plans/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"automattic/jetpack-connection": "^5.0.0"
"automattic/jetpack-connection": "^5.1.0-alpha"
},
"require-dev": {
"yoast/phpunit-polyfills": "^1.1.1",
Expand Down
Loading

0 comments on commit f2dac22

Please sign in to comment.