Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Jul 25, 2014
Merged

[Security] Allow exception bubbling in RememberMeListener #10793

merged 1 commit into from
Jul 25, 2014

Conversation

lstrojny
Copy link
Contributor

  • 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.

@stof
Copy link
Member

stof commented Apr 27, 2014

what is the use case for this ?

@lstrojny
Copy link
Contributor Author

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());
})
)
Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thank you!

@lstrojny lstrojny changed the title Allow exception bubbling in RememberMeListener [Security] Allow exception bubbling in RememberMeListener Apr 27, 2014
@lstrojny
Copy link
Contributor Author

@fabpot anything we need to do before this can be merged?

@fabpot
Copy link
Member

fabpot commented Apr 30, 2014

@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).

@fabpot
Copy link
Member

fabpot commented Jun 15, 2014

👍

@@ -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>
Copy link
Member

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.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@lstrojny
Copy link
Contributor Author

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']);
Copy link
Member

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.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@fabpot
Copy link
Member

fabpot commented Jul 24, 2014

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>
Copy link
Member

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 -->

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@fabpot
Copy link
Member

fabpot commented Jul 24, 2014

looks good to me. ping @symfony/deciders

@lsmith77
Copy link
Contributor

looks good to me too

@fabpot
Copy link
Member

fabpot commented Jul 25, 2014

Thank you @lstrojny.

@fabpot fabpot merged commit fcb7f74 into symfony:master Jul 25, 2014
fabpot added a commit that referenced this pull request Jul 25, 2014
…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
@lstrojny lstrojny deleted the features/rememberme-exception-bubble branch July 25, 2014 08:43
fabpot added a commit that referenced this pull request Jul 26, 2014
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants