Skip to content

[SecurityBundle] fixed DebugAccessDecisionManager config #18566

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

Closed
wants to merge 3 commits into from

Conversation

HeahDude
Copy link
Contributor

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 ~

@linaori
Copy link
Contributor

linaori commented Apr 16, 2016

This is not the way you're supposed to define the decorator. In fact, I would expect this to inject itself and cause a recursive dependency. Maybe there's another bug at hand causing this or is this intended behavior?

@HeahDude
Copy link
Contributor Author

@iltar, I'm not an expert of the DI component but this seems logical if we consider that the decoration is also "hardcoded", see here and here.

If I understand correctly, if the container handles the debug adm as a decorator it is automatically injected and those lines should not be needed, am I missing something ?

This is also how the decorated choice list factories are defined (without using the decorates parameter).

@gharlan
Copy link
Contributor

gharlan commented Apr 18, 2016

@HeahDude thanks for working on this.

I can confirm that it fixes the issue. (But I don't know if it is the "correct" way to fix it.)

@ghost
Copy link

ghost commented Apr 20, 2016

This fix works fine here. Please merge it. 👍

@stof
Copy link
Member

stof commented Apr 20, 2016

The fix does not work fine. It simply means that the debug service will never be used, as it does not replace the original service with the decorated version, making it useless.

so this PR does not fix a bug. It breaks the feature entirely.

@HeahDude
Copy link
Contributor Author

@stof please see the links of my comment above. This fix does not break the feature as tested with the fork linked in #18554.

@stof
Copy link
Member

stof commented Apr 20, 2016

@HeahDude but do you still get the votes in the profiler ? This is what the debug decorator is about.

@HeahDude
Copy link
Contributor Author

Yes it works perfectly fine :)

@HeahDude
Copy link
Contributor Author

Can anyone else (re-)confirm? ping @JHGitty @gharlan

@gharlan
Copy link
Contributor

gharlan commented Apr 20, 2016

Yes I can confirm it. It fixes the bug, and the new access decision log in profiler is still there.

@HeahDude
Copy link
Contributor Author

Thank you @gharlan

@xabbuh
Copy link
Member

xabbuh commented Apr 21, 2016

@stof This works for the core as the injected access decision manager is changed manually in the extension class: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php#L100-L105

However, this will not work if someone injected the default access decision manager somewhere else as those places would now not use the decorated one anymore.

@linaori
Copy link
Contributor

linaori commented Apr 21, 2016

One solution could be the following delegator class in dev:

@Internal
final class VoterProxy implements VoterInterface
{
    private $voterId;
    private $container;

    public function __construct($voterId, ContainerInterface $container)
    {
        $this->voterId = $voterId;
        $this->container = $container;
    }

    public function vote(TokenInterface $token, $subject, array $attributes)
    {
        return $this->container->get($this->voterId)->vote($token, $subject, $attributes);
    }
}

Imo this is the only "clean" solution will will keep working in the future, possible even in prod (though you might want to cache the container get call then)

@HeahDude
Copy link
Contributor Author

HeahDude commented Apr 24, 2016

Ok I've reverted the first fix in a6fce2d and pushed 8e4f98b to fix it while keeping the debug adm injected properly, considering the good point of @xabbuh.

I've tested it was passed to the SecurityDataCollector when removing debug from its argument name in SecurityBundle/Resources/config/collectors.xml using the fork provided in #18554.

If some one could test it again, we should be good now :)

@HeahDude
Copy link
Contributor Author

Actually, the test with the collector is extra safety, since the feature works without overriding security.authorization_checker argument in the config thanks to the last fix.

@HeahDude
Copy link
Contributor Author

There was a major update on this PR wich actually fixes a BC break on 3.1. Anyone for a review?

ping @gharlan @JHGitty @iltar Could you please (re-)confirm it works for you?

Thanks.

@HeahDude
Copy link
Contributor Author

HeahDude commented Apr 25, 2016

Isn't the "critical" label needed when a BC break prevents the application from running?

@gharlan
Copy link
Contributor

gharlan commented Apr 25, 2016

ping @gharlan @JHGitty @iltar Could you please (re-)confirm it works for you?

It works!

@HeahDude
Copy link
Contributor Author

Thank you @gharlan, again :)

@fabpot
Copy link
Member

fabpot commented Apr 28, 2016

Thank you @HeahDude.

@fabpot fabpot closed this Apr 28, 2016
fabpot added a commit that referenced this pull request Apr 28, 2016
…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
@HeahDude HeahDude deleted the fix/debug-adm branch April 28, 2016 10:38
@fabpot fabpot mentioned this pull request May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants