Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Updating AbstractVoter so that the method receives the TokenInterface#15870

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
weaverryan wants to merge2 commits intosymfony:2.8fromweaverryan:abstract-voter

Conversation

weaverryan
Copy link
Member

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed tickets#12360
LicenseMIT
Doc PRnot yet

Thisfixes#12360, and along with already-merged#14733, this would make it possible to make calls back to theAccessDecisionManager inside a voter (e.g. you might check to see ifIS_AUTHENTICATED_FULLY from inside your voter).

We originally passed the User instead of the token to be nice, but it's a limitation, and since we never sanitized the User (i.e. a string may be passed toAbstractToken::isGranted()), it's not helpful anyways.

Thanks!

This fixes issues where people need this token.
if ($this->isGranted($attribute, $object, $token->getUser())) {
// grant access as soon as at least one voter returns a positive response
return self::ACCESS_GRANTED;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This could actually become anelseif { ... }

@linaori
Copy link
Contributor

I think this is a fair compromise for the feature. The namevoteOnAttribute also makes a lot more sense thanisGranted, as this would imply that the voter grants access, while it's only one of many possible voters.

* @param string $attribute
* @param object $object
* @param TokenInterface $token
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you add a note that this method should be abstract in 3.0 so that we do not forget that when cleaning the master branch?

@fabpot
Copy link
Member

👍

@weaverryan
Copy link
MemberAuthor

Done!

Status: Reviewed

@@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Tests\Core\Authentication\Voter;
namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I also realized the test was in the wrong spot - it wasn't moved when the other tests were moved. Fixed that.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nevermind, fixing in a proper PR in 2.7

@fabpot
Copy link
Member

Thank you@weaverryan.

@fabpotfabpot closed thisSep 24, 2015
fabpot added a commit that referenced this pull requestSep 24, 2015
… TokenInterface (weaverryan)This PR was squashed before being merged into the 2.8 branch (closes#15870).Discussion----------Updating AbstractVoter so that the method receives the TokenInterface| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| Fixed tickets |#12360| License       | MIT| Doc PR        | not yetThisfixes#12360, and along with already-merged#14733, this would make it possible to make calls back to the `AccessDecisionManager` inside a voter (e.g. you might check to see if `IS_AUTHENTICATED_FULLY` from inside your voter).We originally passed the User instead of the token to be nice, but it's a limitation, and since we never sanitized the User (i.e. a string may be passed to `AbstractToken::isGranted()`), it's not helpful anyways.Thanks!Commits-------948ccec Updating AbstractVoter so that the method receives the TokenInterface
@@ -65,6 +65,12 @@ public function vote(TokenInterface $token, $object, array $attributes)
// abstain vote by default in case none of the attributes are supported
$vote = self::ACCESS_ABSTAIN;

$reflector = new \ReflectionMethod($this, 'voteOnAttribute');
$isNewOverwritten = $reflector->getDeclaringClass()->getName() !== 'Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would use__CLASS__ here rather than the class name in a string. It makes it clearer than it is the current class, and is less likely to break if we rename things

@weaverryanweaverryan deleted the abstract-voter branchSeptember 26, 2015 14:59
weaverryan added a commit to weaverryan/symfony that referenced this pull requestSep 26, 2015
weaverryan added a commit to weaverryan/symfony that referenced this pull requestSep 26, 2015
weaverryan added a commit to weaverryan/symfony that referenced this pull requestSep 26, 2015
weaverryan added a commit to weaverryan/symfony that referenced this pull requestSep 26, 2015
weaverryan added a commit to weaverryan/symfony that referenced this pull requestSep 26, 2015
fabpot added a commit that referenced this pull requestSep 27, 2015
This PR was merged into the 2.8 branch.Discussion----------Abstract voter tweaks| Q             | A| ------------- | ---| Bug fix?      | yes (a little)| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aBased on suggestions from stof in#15870, this simplifies the BC and deprecation throwing code. This also adds a BadMethodCallException in case the user doesn't override `isGranted` *or* `voteOnAttribute`, because that's just plain wrong (as is calling `isGranted()` on the parent class directly, since that was formerly abstract).Commits-------c03f5c2 Massively simplifying the BC and deprecated-throwing code thanks to suggestions by stof in#15870
fabpot added a commit that referenced this pull requestSep 27, 2015
* 2.8: (28 commits)  Detect Mintty for color support on Windows  Detect Mintty for color support on Windows  [WebProfilerBundle] Fix search button click listener  [Form][Type Date/Time] added choice_translation_domain option.  Massively simplifying the BC and deprecated-throwing code thanks to suggestions by stof in#15870  Making all "debug" messages use the debug router  Making GuardTokenInterface extend TokenInterface  Updating behavior to not continue after an authenticator has set the response  Add a group for tests of the finder against the FTP server  Fix trigger_error calls  Fix legacy security tests  tweaking message related to configuration edge case that we want to be helpful with  Minor tweaks - lowering the required security-http requirement and nulling out a test field  Fix license headers  Fix license headers  Fix license headers  Ensure the ClockMock is loaded before using it in the testsuite  Allow serializer 3.0 in the PropertyInfo component  Add the replace rules for the security-guard component  Forbid serializing a Crawler  ...
@fabpotfabpot mentioned this pull requestNov 16, 2015
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull requestMar 25, 2018
* 2.8: (28 commits)  Detect Mintty for color support on Windows  Detect Mintty for color support on Windows  [WebProfilerBundle] Fix search button click listener  [Form][Type Date/Time] added choice_translation_domain option.  Massively simplifying the BC and deprecated-throwing code thanks to suggestions by stof insymfony#15870  Making all "debug" messages use the debug router  Making GuardTokenInterface extend TokenInterface  Updating behavior to not continue after an authenticator has set the response  Add a group for tests of the finder against the FTP server  Fix trigger_error calls  Fix legacy security tests  tweaking message related to configuration edge case that we want to be helpful with  Minor tweaks - lowering the required security-http requirement and nulling out a test field  Fix license headers  Fix license headers  Fix license headers  Ensure the ClockMock is loaded before using it in the testsuite  Allow serializer 3.0 in the PropertyInfo component  Add the replace rules for the security-guard component  Forbid serializing a Crawler  ...
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@weaverryan@linaori@fabpot@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp