8000 Clarified single attribute to isGranted() a bit more · symfony/symfony@e41e6b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit e41e6b4

Browse files
committed
Clarified single attribute to isGranted() a bit more
Also, allow the array type for a single attribute.
1 parent c187fde commit e41e6b4

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1515
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1616
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
17-
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
1817

1918
/**
2019
* AuthorizationChecker is the main authorization point of the Security component.
@@ -44,7 +43,7 @@ public function __construct(TokenStorageInterface $tokenStorage, AuthenticationM
4443
*
4544
* @throws AuthenticationCredentialsNotFoundException when the token storage has no authentication token
4645
*/
47-
final public function isGranted($attributes, $subject = null): bool
46+
final public function isGranted($attribute, $subject = null): bool
4847
{
4948
if (null === ($token = $this->tokenStorage->getToken())) {
5049
throw new AuthenticationCredentialsNotFoundException('The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL.');
@@ -54,10 +53,6 @@ final public function isGranted($attributes, $subject = null): bool
5453
$this->tokenStorage->setToken($token = $this->authenticationManager->authenticate($token));
5554
}
5655

57-
if (\is_array($attributes)) {
58-
throw new InvalidArgumentException(sprintf('Passing an array of Security attributes to %s() is not supported.', __METHOD__));
59-
}
60-
61-
return $this->accessDecisionManager->decide($token, [$attributes], $subject);
56+
return $this->accessDecisionManager->decide($token, [$attribute], $subject);
6257
}
6358
}

src/Symfony/Component/Security/Core/Authorization/AuthorizationCheckerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ interface AuthorizationCheckerInterface
2121
/**
2222
* Checks if the attributes are granted against the current authentication token and optionally supplied subject.
2323
*
24-
* @param mixed $attributes
24+
* @param mixed $attribute A single attribute to vote on (can be of any type, string and instance of Expression are supported by the core)
2525
* @param mixed $subject
2626
*
2727
* @return bool
2828
*/
29-
public function isGranted($attributes, $subject = null);
29+
public function isGranted($attribute, $subject = null);
3030
}

0 commit comments

Comments
 (0)
0