Skip to content

Commit d83ec43

Browse files
committed
Fix isGranted with object attribute
1 parent d24da0d commit d83ec43

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Authorization/AuthorizationChecker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ final public function isGranted($attributes, $subject = null): bool
5858
throw new InvalidArgumentException(sprintf('Passing an array of Security attributes to %s() is not supported.', __METHOD__));
5959
}
6060

61-
return $this->accessDecisionManager->decide($token, (array) $attributes, $subject);
61+
return $this->accessDecisionManager->decide($token, [$attributes], $subject);
6262
}
6363
}

Tests/Authorization/AuthorizationCheckerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,19 @@ public function isGrantedProvider()
9292
{
9393
return [[true], [false]];
9494
}
95+
96+
public function testIsGrantedWithObjectAttribute()
97+
{
98+
$attribute = new \stdClass();
99+
100+
$token = new UsernamePasswordToken('username', 'password', 'provider', ['ROLE_USER']);
101+
102+
$this->accessDecisionManager
103+
->expects($this->once())
104+
->method('decide')
105+
->with($this->identicalTo($token), $this->identicalTo([$attribute]))
106+
->willReturn(true);
107+
$this->tokenStorage->setToken($token);
108+
$this->assertTrue($this->authorizationChecker->isGranted($attribute));
109+
}
95110
}

0 commit comments

Comments
 (0)