-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] Allow exception bubbling in RememberMeListener #10793
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
[Security] Allow exception bubbling in RememberMeListener #10793
Conversation
what is the use case for this ? |
For example we want to display a special error page depending on the status of a user. To manage that in the EntryPoint, the exception needs to bubble to the ExceptionListener. |
$this->assertSame($request, $event->getRequest()); | ||
$this->assertSame($token, $event->getAuthenticationToken()); | ||
}) | ||
) |
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.
$this
wasn't available in anonymous functions until PHP 5.4 (notice the tests failing).
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.
Fixed, thank you!
@fabpot anything we need to do before this can be merged? |
@lstrojny We are in the stabilisation phase of Symfony 2.5, so I'm not looking at new features at the moment, only bug fixes (master is still 2.5, not 2.6@dev yet). |
👍 |
@@ -8,6 +8,7 @@ | |||
<parameter key="security.authentication.provider.rememberme.class">Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider</parameter> | |||
|
|||
<parameter key="security.authentication.listener.rememberme.class">Symfony\Component\Security\Http\Firewall\RememberMeListener</parameter> | |||
<parameter key="security.authentication.listener.rememberme.catch_exceptions">true</parameter> |
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.
This parameter should be removed and injected by the DI extension instead (that's how we do things everywhere else.)
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.
Fixed!
Alright, added configuration handling and tests for it. Squashed the commits, hope it’s fine for a merge now. |
@@ -102,6 +102,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider, | |||
$listenerId = 'security.authentication.listener.rememberme.'.$id; | |||
$listener = $container->setDefinition($listenerId, new DefinitionDecorator('security.authentication.listener.rememberme')); | |||
$listener->replaceArgument(1, new Reference($rememberMeServicesId)); | |||
$listener->replaceArgument(4, $config['catch_exceptions']); |
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.
You need to add a comment in the XML definition (like for the other argument.)
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.
Added.
Besides the small comment I've just made, everything else looks good to me. |
@@ -24,13 +24,14 @@ | |||
<argument type="service" id="security.authentication.manager" /> | |||
<argument type="service" id="logger" on-invalid="null" /> | |||
<argument type="service" id="event_dispatcher" on-invalid="null"/> | |||
<argument>true</argument> |
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.
Sorry, I should have told you what I expected here. It was more something like <argument /> <!-- Catch exception flag -->
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.
Fixed
looks good to me. ping @symfony/deciders |
looks good to me too |
Thank you @lstrojny. |
…ner (lstrojny) This PR was merged into the 2.6-dev branch. Discussion ---------- [Security] Allow exception bubbling in RememberMeListener - Allow optional exception bubbling so that the exception listener has a chance to handle those exceptions #### While at it - Test for dispatching the InteractiveLogin event - Smaller cleanups in the test | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | ye | Fixed tickets | n.A. | License | MIT | Doc PR | n.A. Commits ------- fcb7f74 Allow exception bubbling in RememberMeListener
This PR was merged into the 2.6-dev branch. Discussion ---------- [SecurityBundle] fix constructor argument index | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #10793 | License | MIT | Doc PR | As @excelwebzone pointed out in fb9dc6a, `catchExceptions` is the 6th argument of the RememberMeListener constructor. Commits ------- a32646e [SecurityBundle] fix constructor argument index
While at it