Skip to content

Commit

Permalink
Fixed ability to save config by a user with limited access (#496)
Browse files Browse the repository at this point in the history
Related to configs that uses 'config_path' parameter only -
payment config section for example.
  • Loading branch information
vovayatsyuk authored and Flyingmana committed Jun 23, 2019
1 parent 097ef2d commit 3db1bfc
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion app/code/core/Mage/Adminhtml/Model/Config/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public function save()
if (is_object($fieldConfig)) {
$configPath = (string)$fieldConfig->config_path;
if (!empty($configPath) && strrpos($configPath, '/') > 0) {
if (!Mage::getSingleton('admin/session')->isAllowed($configPath)) {
$parts = explode('/', $configPath);
if (!$this->_isSectionAllowed($parts[0])) {
Mage::throwException('Access denied.');
}
// Extend old data with specified section group
Expand Down Expand Up @@ -244,6 +245,30 @@ public function extendConfig($path, $full = true, $oldConfig = array())
return $extended;
}

/**
* Check if specified section allowed in ACL
*
* Taken from Mage_Adminhtml_System_ConfigController::_isSectionAllowed
*
* @param string $section
* @return bool
*/
protected function _isSectionAllowed($section)
{
try {
$session = Mage::getSingleton('admin/session');
$resourceLookup = "admin/system/config/{$section}";
if ($session->getData('acl') instanceof Mage_Admin_Model_Acl) {
return $session->isAllowed(
$session->getData('acl')->get($resourceLookup)->getResourceId()
);
}
} catch (Exception $e) {
return false;
}
return false;
}

/**
* Validate isset required parametrs
*
Expand Down

0 comments on commit 3db1bfc

Please sign in to comment.