Skip to content

Commit 68cb9ec

Browse files
Tomasz-Silpionkiatngfballiano
authored
Fix admin ACL mismatch for OAuth (#3272) (#3274)
Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com> Co-authored-by: Fabrizio Balliano <fabrizio.balliano@gmail.com>
1 parent 58be830 commit 68cb9ec

File tree

7 files changed

+53
-9
lines changed

7 files changed

+53
-9
lines changed

.all-contributorsrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,16 @@
13911391
"contributions": [
13921392
"code"
13931393
]
1394-
}
1394+
},
1395+
{
1396+
"login": "Tomasz-Silpion",
1397+
"name": "Tomasz Gregorczyk",
1398+
"avatar_url": "https://avatars.githubusercontent.com/u/5328659?v=4",
1399+
"profile": "https://github.com/Tomasz-Silpion",
1400+
"contributions": [
1401+
"code"
1402+
]
1403+
},
13951404
],
13961405
"contributorsPerLine": 7
13971406
}

app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,6 @@ protected function _isAllowed()
155155
{
156156
/** @var Mage_Admin_Model_Session $session */
157157
$session = Mage::getSingleton('admin/session');
158-
return $session->isAllowed('system/acl/admin_token');
158+
return $session->isAllowed('system/api/oauth_admin_token');
159159
}
160160
}

app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected function _isAllowed()
149149
{
150150
/** @var Mage_Admin_Model_Session $session */
151151
$session = Mage::getSingleton('admin/session');
152-
return $session->isAllowed('system/oauth/authorizedTokens');
152+
return $session->isAllowed('system/api/oauth_authorized_tokens');
153153
}
154154

155155
/**

app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/ConsumerController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ protected function _isAllowed()
240240
}
241241
/** @var Mage_Admin_Model_Session $session */
242242
$session = Mage::getSingleton('admin/session');
243-
return $session->isAllowed('system/oauth/consumer' . $action);
243+
return $session->isAllowed('system/api/oauth_consumer' . $action);
244244
}
245245

246246
/**
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* OpenMage
4+
*
5+
* This source file is subject to the Open Software License (OSL 3.0)
6+
* that is bundled with this package in the file LICENSE.txt.
7+
* It is also available at https://opensource.org/license/osl-3-0-php
8+
*
9+
* @category Mage
10+
* @package Mage_Admin
11+
* @copyright Copyright (c) 2023 The OpenMage Contributors (https://www.openmage.org)
12+
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
13+
*/
14+
15+
/** @var Mage_Core_Model_Resource_Setup $installer */
16+
$installer = $this;
17+
$installer->startSetup();
18+
19+
$table = $installer->getTable('admin/rule');
20+
$resourceIds = [
21+
'admin/system/api/consumer' => 'admin/system/api/oauth_consumer',
22+
'admin/system/api/consumer/delete' => 'admin/system/api/oauth_consumer/delete',
23+
'admin/system/api/consumer/edit' => 'admin/system/api/oauth_consumer/edit',
24+
'admin/system/api/authorizedTokens' => 'admin/system/api/oauth_authorized_tokens'
25+
];
26+
27+
foreach ($resourceIds as $oldId => $newId) {
28+
$installer->getConnection()->update(
29+
$table,
30+
['resource_id' => $newId],
31+
['resource_id = ?' => $oldId]
32+
);
33+
}
34+
35+
$installer->endSetup();

app/code/core/Mage/Oauth/etc/adminhtml.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<children>
2424
<api>
2525
<children>
26-
<consumer translate="title" module="oauth">
26+
<oauth_consumer translate="title" module="oauth">
2727
<title>OAuth Consumers</title>
2828
<sort_order>20</sort_order>
2929
<children>
@@ -36,11 +36,11 @@
3636
<sort_order>40</sort_order>
3737
</delete>
3838
</children>
39-
</consumer>
40-
<authorizedTokens translate="title" module="oauth">
39+
</oauth_consumer>
40+
<oauth_authorized_tokens translate="title" module="oauth">
4141
<title>OAuth Authorized Tokens</title>
4242
<sort_order>30</sort_order>
43-
</authorizedTokens>
43+
</oauth_authorized_tokens>
4444
<oauth_admin_token translate="title" module="oauth">
4545
<title>OAuth Admin My Apps</title>
4646
<sort_order>40</sort_order>

app/code/core/Mage/Oauth/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<config>
1818
<modules>
1919
<Mage_Oauth>
20-
<version>1.0.0.0</version>
20+
<version>1.0.0.1</version>
2121
</Mage_Oauth>
2222
</modules>
2323
<global>

0 commit comments

Comments
 (0)