Skip to content

Commit 49744ae

Browse files
committed
ACP2E-277: treat missing rules from authorization_rule table as deny permission rules.
1 parent 67ee5ff commit 49744ae

File tree

1 file changed

+18
-0
lines changed
  • app/code/Magento/Authorization/Model/Acl/Loader

1 file changed

+18
-0
lines changed

app/code/Magento/Authorization/Model/Acl/Loader/Rule.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ public function __construct(
8080
*/
8181
public function populateAcl(\Magento\Framework\Acl $acl)
8282
{
83+
$foundResources = [];
84+
$foundRoles = [];
85+
8386
foreach ($this->getRulesArray() as $rule) {
8487
$role = $rule['role_id'];
8588
$resource = $rule['resource_id'];
8689
$privileges = !empty($rule['privileges']) ? explode(',', $rule['privileges']) : null;
8790

8891
if ($acl->has($resource)) {
92+
$foundResources[$resource] = $resource;
93+
$foundRoles[$role] = $role;
8994
if ($rule['permission'] == 'allow') {
9095
if ($resource === $this->_rootResource->getId()) {
9196
$acl->allow($role, null, $privileges);
@@ -96,6 +101,19 @@ public function populateAcl(\Magento\Framework\Acl $acl)
96101
}
97102
}
98103
}
104+
105+
/**
106+
* for all rules that were not regenerated in authorization_rule table,
107+
* when adding a new module and without re-saving all roles,7
108+
* consider not present rules with deny permissions
109+
* */
110+
foreach ($acl->getResources() as $resource) {
111+
if (!isset($foundResources[$resource])) {
112+
foreach ($foundRoles as $role) {
113+
$acl->deny($role, $resource, null);
114+
}
115+
}
116+
}
99117
}
100118

101119
/**

0 commit comments

Comments
 (0)