8000 [5.0][Security] Minor clarification of the new isGranted signature by wouterj · Pull Request #34074 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[5.0][Security] Minor clarification of the new isGranted signature #34074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9F80
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;

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

if (\is_array($attributes)) {
throw new InvalidArgumentException(sprintf('Passing an array of Security attributes to %s() is not supported.', __METHOD__));
}

return $this->accessDecisionManager->decide($token, [$attributes], $subject);
return $this->accessDecisionManager->decide($token, [$attribute], $subject);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ interface AuthorizationCheckerInterface
/**
* Checks if the attributes are granted against the current authentication token and optionally supplied subject.
*
* @param mixed $attributes
* @param mixed $attribute A single attribute to vote on (can be of any type, string and instance of Expression are supported by the core)
* @param mixed $subject
*
* @return bool
*/
public function isGranted($attributes, $subject = null);
public function isGranted($attribute, $subject = null);
}
0