Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix admin ACL mismatch for OAuth (#3272) #3274

Merged
merged 11 commits into from
May 21, 2023
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* OpenMage
*
* 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 at https://opensource.org/license/osl-3-0-php
*
* @category Mage
* @package Mage_Admin
* @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)
*/

/** @var Mage_Core_Model_Resource_Setup $installer */
$installer = $this;
$installer->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();
8 changes: 4 additions & 4 deletions app/code/core/Mage/Oauth/etc/adminhtml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<children>
<api>
<children>
<consumer translate="title" module="oauth">
<oauth_consumer translate="title" module="oauth">
<title>OAuth Consumers</title>
<sort_order>20</sort_order>
<children>
Expand All @@ -36,11 +36,11 @@
<sort_order>40</sort_order>
</delete>
</children>
</consumer>
<authorizedTokens translate="title" module="oauth">
</oauth_consumer>
<oauth_authorized_tokens translate="title" module="oauth">
<title>OAuth Authorized Tokens</title>
<sort_order>30</sort_order>
</authorizedTokens>
</oauth_authorized_tokens>
<oauth_admin_token translate="title" module="oauth">
<title>OAuth Admin My Apps</title>
<sort_order>40</sort_order>
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Oauth/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<config>
<modules>
<Mage_Oauth>
<version>1.0.0.0</version>
<version>1.0.0.1</version>
</Mage_Oauth>
</modules>
<global>
Expand Down