-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Continuation : Add messages and score on votes #58107
base: 7.2
Are you sure you want to change the base?
Conversation
5a4fbe1
to
fc77e53
Compare
src/Symfony/Component/Security/Core/Authorization/AccessDecision.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Core/Authorization/AccessDecision.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Core/Authorization/Voter/Vote.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Core/Authorization/Voter/Vote.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Core/Authorization/Voter/VoteInterface.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Core/Authorization/Voter/VoteInterface.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Core/Exception/AccessDeniedException.php
Outdated
Show resolved
Hide resolved
6e67169
to
71d7744
Compare
@eltharin hi 👋🏻 nice to see that you are willing to take over this amount of work, incremented overtime by different coders and reviewers :) i am still interested in such feature even though now I rarely use voter, still thinking that this can be a great addition in core (like workflow transition blocker message is available) to be honest, I think I would probable split this in 2 separates PRs, just to ease review and reduce the friction already existing around such feature, as it needs to arrive on a simple/BC/evolutive/maintainable way in core
in any way, I will add a reminder to make a review on this PR as well :) ( PS: @noniagriconomie is one old account of mine no more used since ) |
you and other are the firsts to thank for the start of this work, For the 2 PR's I thought about it but it's absolutlly linked, both needs Vote Object so getVote function so GetDecision functions, Remove first or second feature but keep other one will only touch few files compared with all files changed. At start, i saw your PR's without really needed, but when I wrote myine for scoring, I saw I made the same work as you, so I included your work in these to not have conflict when one will be accepted. As it's a big update to add all these functions in symfony core I add a new benefit to this to have more chance to see this PR passed :) |
46b15e0
to
e9f63ce
Compare
Did anyone ever run performance checks on these changes? Considering that Voters can be called hundreds of times per request, any overhead created by hundreds of new Vote() instances or checks for existing methods should imo be avoided (e.g. add new interfaces so I can opt-in to the new approach, instead of forcing the code upon everyone). |
e9f63ce
to
278f259
Compare
src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php
Show resolved
Hide resolved
src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php
Show resolved
Hide resolved
src/Symfony/Component/Security/Core/Authorization/Strategy/ScoringStrategy.php
Outdated
Show resolved
Hide resolved
@@ -40,29 +43,38 @@ public function __construct( | |||
|
|||
public function decide(\Traversable $results): bool | |||
{ | |||
return $this->getDecision(new \ArrayIterator(array_map(fn ($vote) => new Vote($vote), iterator_to_array($results))))->isGranted(); |
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.
perhaps create a trait to avoid copy/past such internal ?
src/Symfony/Component/Security/Core/Authorization/Voter/Vote.php
Outdated
Show resolved
Hide resolved
fabpot use interface
278f259
to
84f75b9
Compare
I look with Symfony Profiler, with 3000 voters With 7.2 actual version VoteListener take 120MiB in 8ms with this PR, 118MiB for 8.4ms. |
friendly ping @chalasr as default reviewer |
This PR continue the work started by @maidmaid and @noniagriconomie in #35592, continued by @yellow1912 in #43147 continued by @alamirault in #46493.
I rebase on 7.2 and remove deprecation as suggested by nicolas-grekas for not causing backward compatiblity breaks.
It allow to have informations about AccessDecisionManager and Voters (And understand why we have an AccessDeniedException with clear infos).

I add possibility to respond a voter with a score and create a Scoring strategy, looks like consensus but with ponderation.