-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] remove support for defining voters that don't implement VoterInterface. #23324
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
Conversation
hhamon
commented
Jun 28, 2017
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | no |
BC breaks? | yes |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | ~ |
License | MIT |
Doc PR | ~ |
84f6f5c
to
4b91fb5
Compare
UPGRADE-4.0.md
Outdated
@@ -455,6 +455,8 @@ Security | |||
* The `AccessDecisionManager::setVoters()` method has been removed. Pass the | |||
voters to the constructor instead. | |||
|
|||
* Defining voters that don't implement the `VoterInterface` interface has been removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support for defining [...]
if (!method_exists($class, 'vote')) { | ||
// in case the vote method is completely missing, to prevent exceptions when voting | ||
throw new LogicException(sprintf('%s should implement the %s interface when used as voter.', $class, VoterInterface::class)); | ||
throw new LogicException(sprintf('%s must implement the %s interface when used as voter.', $class, VoterInterface::class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the "interface" here (it's already part of the interface name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] used as a voter.
@@ -8,7 +8,8 @@ CHANGELOG | |||
You should implement this method yourself in your concrete authenticator. | |||
* removed the `AccessDecisionManager::setVoters()` method | |||
* removed the `RoleInterface` | |||
* added a sixth `string $context` argument to`LogoutUrlGenerator::registerListener()` | |||
* removed support for voters that don't implement the `VoterInterface` interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove "interface" here
* | ||
* @deprecated as of 3.4 and will be removed in 4.0. Call the voter directly as the instance will always be a VoterInterface | ||
*/ | ||
private function vote($voter, TokenInterface $token, $subject, $attributes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could now update the docblock of the constructor so that the type hint for the $voters
argument is now VoterInterface[]
instead of iterable|VoterInterface[]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum I'm not sure! It seems that SecurityBundle passes an iterator argument to the access decision manager so that voters can be lazy loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// AddSecurityVotersPass.php
$adm = $container->getDefinition('security.access.decision_manager');
$adm->replaceArgument(0, new IteratorArgument($voters));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can only change the dockblock but not the signature as passing iterators must still be allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VoterInterface[]
means array of VoterInterface instances
. So we cannot remove iterable
from the phpdoc, otherwise we effectively remove the support of iterators from our supported usage (and so from our BC promise). This is quite problematic when our own usage relies on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, I thought VoterInterface[]
means something I can iterate over.
4b91fb5
to
7c400d9
Compare
Changes applied. |
7c400d9
to
1bb6f73
Compare
@@ -8,7 +8,8 @@ CHANGELOG | |||
You should implement this method yourself in your concrete authenticator. | |||
* removed the `AccessDecisionManager::setVoters()` method | |||
* removed the `RoleInterface` | |||
* added a sixth `string $context` argument to`LogoutUrlGenerator::registerListener()` | |||
* removed support for voters that don't implement the `VoterInterface` | |||
* added a sixth `string $context` argument to`LogoutUrlGenerator::registerListener()` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't add a trailing whitespace in this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups was a mistake.
@@ -33,7 +32,7 @@ class AccessDecisionManager implements AccessDecisionManagerInterface | |||
private $allowIfEqualGrantedDeniedDecisions; | |||
|
|||
/** | |||
* @param iterable|VoterInterface[] $voters An iterator of VoterInterface instances | |||
* @param iterable|VoterInterface[] $voters An array (or an iterator) of VoterInterface instances |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not put t in braces
1bb6f73
to
3db09a6
Compare
@stof fixed |
…e VoterInterface interface.
3db09a6
to
f527790
Compare
Thank you @hhamon. |
…'t implement VoterInterface. (hhamon) This PR was merged into the 4.0-dev branch. Discussion ---------- [Security] remove support for defining voters that don't implement VoterInterface. | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Commits ------- f527790 [Security] remove support for defining voters that don't implement the VoterInterface interface.