From 832137725bbd41158dcc1ab8e91feed8cc623fd3 Mon Sep 17 00:00:00 2001 From: Tomasz Gregorczyk Date: Thu, 18 May 2023 03:10:25 +0200 Subject: [PATCH 1/8] Add @Tomasz-Silpion as a contributor (#3272) --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index e2ce8b9ae93..d452321b98b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1382,6 +1382,15 @@ "contributions": [ "code" ] + }, + { + "login": "Tomasz-Silpion", + "name": "Tomasz Gregorczyk", + "avatar_url": "https://avatars.githubusercontent.com/u/5328659?v=4", + "profile": "https://github.com/Tomasz-Silpion", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7 From 7ffebf7b937f7556f50e5109adafa2843c66e4e2 Mon Sep 17 00:00:00 2001 From: Tomasz Gregorczyk Date: Fri, 19 May 2023 05:26:37 +0200 Subject: [PATCH 2/8] Fix admin ACL mismatch for OAuth (#3272) --- .../controllers/Adminhtml/Oauth/Admin/TokenController.php | 2 +- .../Adminhtml/Oauth/AuthorizedTokensController.php | 2 +- .../controllers/Adminhtml/Oauth/ConsumerController.php | 2 +- app/code/core/Mage/Oauth/etc/adminhtml.xml | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php index 6914471f929..1e51d84dbb9 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php @@ -155,6 +155,6 @@ protected function _isAllowed() { /** @var Mage_Admin_Model_Session $session */ $session = Mage::getSingleton('admin/session'); - return $session->isAllowed('system/acl/admin_token'); + return $session->isAllowed('system/api/oauth_admin_token'); } } diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php index 55b0e372bc9..d6a1b9e84c6 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php @@ -149,7 +149,7 @@ protected function _isAllowed() { /** @var Mage_Admin_Model_Session $session */ $session = Mage::getSingleton('admin/session'); - return $session->isAllowed('system/oauth/authorizedTokens'); + return $session->isAllowed('system/api/oauth_authorized_tokens'); } /** diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php index fbf8056771d..bc25301639d 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php @@ -240,7 +240,7 @@ protected function _isAllowed() } /** @var Mage_Admin_Model_Session $session */ $session = Mage::getSingleton('admin/session'); - return $session->isAllowed('system/oauth/consumer' . $action); + return $session->isAllowed('system/api/oauth_consumer' . $action); } /** diff --git a/app/code/core/Mage/Oauth/etc/adminhtml.xml b/app/code/core/Mage/Oauth/etc/adminhtml.xml index 1e6ea5d4ed0..dc2f3c02664 100644 --- a/app/code/core/Mage/Oauth/etc/adminhtml.xml +++ b/app/code/core/Mage/Oauth/etc/adminhtml.xml @@ -23,7 +23,7 @@ - + OAuth Consumers 20 @@ -36,11 +36,11 @@ 40 - - + + OAuth Authorized Tokens 30 - + OAuth Admin My Apps 40 From 3cfee60cdab98c1f68bb78c5787a209adf9b3739 Mon Sep 17 00:00:00 2001 From: Tomasz Gregorczyk Date: Fri, 19 May 2023 06:14:14 +0200 Subject: [PATCH 3/8] Remove obsolete ACL resources from DB (#3272) --- app/code/core/Mage/Oauth/etc/config.xml | 2 +- .../oauth_setup/upgrade-1.0.0.0-1.0.0.1.php | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 app/code/core/Mage/Oauth/sql/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php diff --git a/app/code/core/Mage/Oauth/etc/config.xml b/app/code/core/Mage/Oauth/etc/config.xml index d1745e635aa..ccf844d1660 100644 --- a/app/code/core/Mage/Oauth/etc/config.xml +++ b/app/code/core/Mage/Oauth/etc/config.xml @@ -17,7 +17,7 @@ - 1.0.0.0 + 1.0.0.1 diff --git a/app/code/core/Mage/Oauth/sql/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php b/app/code/core/Mage/Oauth/sql/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php new file mode 100644 index 00000000000..f4998a48f24 --- /dev/null +++ b/app/code/core/Mage/Oauth/sql/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php @@ -0,0 +1,32 @@ +startSetup(); + +$obsoleteAcl = [ + 'admin/system/api/consumer', + 'admin/system/api/consumer/edit', + 'admin/system/api/consumer/delete', + 'admin/system/api/authorizedTokens' +]; + +$installer->getConnection()->delete( + $installer->getTable('admin/rule'), + ['resource_id IN (?)' => $obsoleteAcl] +); + +$installer->endSetup(); From dd968278781fe34d5abfc7f8e3fa1399bd4f571b Mon Sep 17 00:00:00 2001 From: Ng Kiat Siong Date: Fri, 19 May 2023 12:48:04 +0800 Subject: [PATCH 4/8] Upgrade script to update obsolete `resource_id` in table `admin_rule`. --- .../oauth_setup/upgrade-1.0.0.0-1.0.0.1.php | 42 +++++++++++++++++++ app/code/core/Mage/Oauth/etc/config.xml | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php diff --git a/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php b/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php new file mode 100644 index 00000000000..39ac8761914 --- /dev/null +++ b/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php @@ -0,0 +1,42 @@ +startSetup(); + +$table = $installer->getTable('admin/rule'); +$resourceIds = [ + 'admin/system/api/consumer' => 'admin/system/api/oauth_consumer', + 'admin/system/api/consumer/delete' => 'admin/system/api/oauth_consumer/delete', + 'admin/system/api/consumer/edit' => 'admin/system/api/oauth_consumer/edit', + 'admin/system/api/authorizedTokens' => 'admin/system/api/oauth_authorized_tokens' +]; + +foreach ($resourceIds as $oldId => $newId) { + $installer->getConnection()->update( + $table, + ['resource_id' => $newId], + ['resource_id = ?' => $oldId] + ); +} + +$installer->endSetup(); \ No newline at end of file diff --git a/app/code/core/Mage/Oauth/etc/config.xml b/app/code/core/Mage/Oauth/etc/config.xml index d1745e635aa..ccf844d1660 100644 --- a/app/code/core/Mage/Oauth/etc/config.xml +++ b/app/code/core/Mage/Oauth/etc/config.xml @@ -17,7 +17,7 @@ - 1.0.0.0 + 1.0.0.1 From b69ba5f10a76293e41e90835475e99eb25970628 Mon Sep 17 00:00:00 2001 From: Ng Kiat Siong Date: Fri, 19 May 2023 13:13:09 +0800 Subject: [PATCH 5/8] Update upgrade-1.0.0.0-1.0.0.1.php Fixed CS complaint. --- .../Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php b/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php index 39ac8761914..0d861aadc19 100644 --- a/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php +++ b/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php @@ -39,4 +39,4 @@ ); } -$installer->endSetup(); \ No newline at end of file +$installer->endSetup(); From da84707ce23159f3956de05779827b93f9634d63 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 19 May 2023 08:28:36 +0100 Subject: [PATCH 6/8] license update --- .../Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php b/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php index 0d861aadc19..4ba6ee2ce81 100644 --- a/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php +++ b/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php @@ -2,15 +2,9 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * * @category Mage * @package Mage_Admin From de62731c003f98c2e719dc5c338caea93eb11bec Mon Sep 17 00:00:00 2001 From: Ng Kiat Siong Date: Fri, 19 May 2023 15:36:02 +0800 Subject: [PATCH 7/8] Delete upgrade-1.0.0.0-1.0.0.1.php This is unnecessary. --- .../oauth_setup/upgrade-1.0.0.0-1.0.0.1.php | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 app/code/core/Mage/Oauth/sql/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php diff --git a/app/code/core/Mage/Oauth/sql/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php b/app/code/core/Mage/Oauth/sql/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php deleted file mode 100644 index f4998a48f24..00000000000 --- a/app/code/core/Mage/Oauth/sql/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php +++ /dev/null @@ -1,32 +0,0 @@ -startSetup(); - -$obsoleteAcl = [ - 'admin/system/api/consumer', - 'admin/system/api/consumer/edit', - 'admin/system/api/consumer/delete', - 'admin/system/api/authorizedTokens' -]; - -$installer->getConnection()->delete( - $installer->getTable('admin/rule'), - ['resource_id IN (?)' => $obsoleteAcl] -); - -$installer->endSetup(); From c5666e0c8dbc50cd0aa8270f470b57966a087497 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 19 May 2023 09:19:06 +0100 Subject: [PATCH 8/8] docblock --- .../core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php b/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php index 4ba6ee2ce81..fd764978c23 100644 --- a/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php +++ b/app/code/core/Mage/Oauth/data/oauth_setup/upgrade-1.0.0.0-1.0.0.1.php @@ -8,7 +8,6 @@ * * @category Mage * @package Mage_Admin - * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) * @copyright Copyright (c) 2023 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */