Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Security] Add the ability for voter to return decision reason#43147
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Sometimes we need to know why the voter makes a certain decision.This changes allows us to return a vote object which contains a reason.
carsonbot commentedSep 23, 2021
Hey! I see that this is your first PR. That is great! Welcome! Symfony has acontribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
We cannot use the interface at the moment because the new methodis not available in the interface yet.We also cannot put the new method inside the interface because itcan break current/old code.
src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Authorization/AccessDecisionManagerInterface.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Authorization/Voter/AccessTrait.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Authorization/Voter/AccessTrait.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Authorization/Voter/Voter.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Security/Core/Exception/AccessDeniedException.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
1. Add missing getDecision method to AuthorizationChecker2. Do not force int return on TraceableVoter::vote for now
1. Change internal methods from public to protected2. Remove useless phpdoc
Add missing message passed through constructor
@yellow1912 thank you taking over this! Feel free to ping me when you consider this PR finaly reviewable, I will be glad to do so 👍 |
@noniagriconomie can you check and let me know if there is anything else I should fix? I see unittests still fail but not entirely sure why, I see only notices. |
@yellow1912 unfortunatly, i may not be the best to answer |
@stof Please let me know if:
|
I'll take time to test this thoroughly during the last week of October. My main concern is about the BC layer, for 3rd party bundles especially, but I feel like we are quite close. |
@chalasr Have you got the time to take a look at this? Once you checked everything I can update it to 6.x instead because it seems like 5.x is closed now. |
@yellow1912 We will need to make this happen on 6.1, yes. The core team' focus is currently about stabilizing core code/docs and syncing community projects for 5.4 and 6.0. I will revisit this early in the 6.1 development stage. Thanks for your patience. |
In the meantime, you can already rebase onto the 6.0 branch (6.1 is not open yet) which also means you can use all the juicy new PHP 8.0 features. 😎 |
@yellow1912 I've reminded myself this PR, did you had time/energy to rebase it for sf v6? thank you :) |
I haven't got the time to do that, but I will try to finish it within the next 2 weeks, too many things on my disk at the moment. |
fabpot commentedJul 22, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Closing in favor of#46493 |
…e (nicolas-grekas)This PR was merged into the 7.3 branch.Discussion----------[Security] Add ability for voters to explain their vote| Q | A| ------------- | ---| Branch? | 7.3| Bug fix? | no| New feature? | no| Deprecations? | no| Issues |Fix#27995,#26343,#35592,#43147| License | MITThis PR takes over#58107, which itself took over from#46493, etc.It takes the only approach I could think of that would preserve BC.The visible tip of what this achieves is:Internally, this provides a new access audit log infrastructure that relies on new `AccessDecision` and `Vote` objects.Note that I didn't add (nor fix) tests for now. I'll borrow (and credit) from#58107 /#46493 as much as possible.Commits-------c6eb9ae [Security] Add ability for voters to explain their vote
Uh oh!
There was an error while loading.Please reload this page.
Sometimes we need to know why the voter makes a certain decision.
This changes allows us to return a vote object which contains a reason.
This is a PR continuing the work started by@maidmaid and@noniagriconomie in#35592
All the code is contributed by azjezz, I only merge the changes into 5.4 branch since he/she does not have time right now.
(Original PR:#40711)
The initial PR is meant to see if all tests passed (I expect tests to fail). More changes will come later since this PR contains BC.