Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 0cba0c7

Browse files
committed
bug #34304 [Security] Fix defining multiple roles per access_control rule (chalasr)
This PR was merged into the 4.4 branch. Discussion ---------- [Security] Fix defining multiple roles per access_control rule | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | symfony/symfony-docs#12371 needs to be reverted #33584 deprecated passing multiple attributes to `AccessDecisionManager::decide()`, but this change must not impact `access_control` as you cannot define multiple rules with the same criteria for request matching (the first match wins). Commits ------- 338b3dfd9f [Security] Fix defining multiple roles per access_control rule
2 parents 0a1081e + 1d6379b commit 0cba0c7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Http/Firewall/AccessListener.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,14 @@ public function __invoke(RequestEvent $event)
6868
$this->tokenStorage->setToken($token);
6969
}
7070

71-
if (!$this->accessDecisionManager->decide($token, $attributes, $request)) {
71+
$granted = false;
72+
foreach ($attributes as $key => $value) {
73+
if ($this->accessDecisionManager->decide($token, [$key => $value], $request)) {
74+
$granted = true;
75+
}
76+
}
77+
78+
if (!$granted) {
7279
$exception = new AccessDeniedException();
7380
$exception->setAttributes($attributes);
7481
$exception->setSubject($request);

0 commit comments

Comments
 (0)