-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
AccessDecisionManager can not be injected into Voter anymore #18554
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
Comments
@gharlan can you verify if it does work without dev? I think the issue could be related to a service only loaded in dev. Possibly introduced in #17887, can you verify this? /cc @javiereguiluz |
I can confirm this.
|
@iltar do you have any clue about how to fix this? Thanks! |
@javiereguiluz I can't seem to find a fix for this just yet. I've encountered this issue myself for a completely other case (if I inject the ADM in my voter): Circular reference detected for service "debug.security.access.decision_manager", path: "
cache_warmer
-> hostnet_webpack.bridge.cache_warmer
-> hostnet_webpack.bridge.asset_compiler
-> hostnet_webpack.bridge.asset_twig_parser
-> twig
-> security.authorization_checker
-> debug.security.access.decision_manager
-> app.security.voter.contract". This one is created because of the SecurityExtension in the TwigBridge. If I lazy load the service by injecting the container here, it works fine and I get the above error. I'm not entirely sure why that error is present, but this is in fact a circular reference. When creating the voter, it needs to inject the access decision manager and this one needs the voters. I'm curious how this can work in the first place. Imo the access decision manager should not be directly accessible in another voter and the container should be injected instead. One option you could do is to wrap the container in an implementation using the designated ADM interface. |
See #18566, tested with the fork. |
Same issue here, hopefully to get a fast fix for this. I really like to use Symfony 3.1.* :) |
@javiereguiluz The fix in #18566 works fine here. Please merge it! 👍 |
Is there any valid reason to have access to the ADM inside a voter? It does sound weird to me! |
@hhamon checking for roles inside the voter. See: http://symfony.com/doc/current/cookbook/security/voters.html#checking-for-roles-inside-a-voter |
For this use case I just inject the |
…HeahDude) This PR was squashed before being merged into the 3.1-dev branch (closes #18566). Discussion ---------- [SecurityBundle] fixed DebugAccessDecisionManager config | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18554 | License | MIT | Doc PR | ~ Commits ------- 53c78fe [SecurityBundle] fixed DebugAccessDecisionManager config
http://symfony.com/doc/master/cookbook/security/voters.html#checking-for-roles-inside-a-voter
This works with current release (3.0.4), but not with current master.
I get this error:
Reproducible by this branch of symfony-standard:
https://github.com/gharlan/symfony-standard/tree/voter-with-decision-manager
You can see the error in
composer install
(ScriptHandler::clearCache).The text was updated successfully, but these errors were encountered: