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

Skip to content

Fix for issue 1798 #2528

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 2 commits into from
Nov 10, 2011
Merged

Fix for issue 1798 #2528

merged 2 commits into from
Nov 10, 2011

Conversation

snc
Copy link
Contributor

@snc snc commented Oct 31, 2011

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes

Clear session cookie if user was deleted, is disabled or locked to prevent infinite redirect loops to the login path (fixes #1798).

…event infinite redirect loops to the login path (fixes symfony#1798).

if ($authException instanceof AccountStatusException && $response instanceof Response) {
// clear the session cookie to prevent infinite redirect loops
$cookieParams = session_get_cookie_params();
Copy link
Member

Choose a reason for hiding this comment

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

You should not clear the whole session cookie but only the security stuff (what if the application stores other things in the cookies ?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my application I store other settings in the session, too, and those are of cause user related, too, so at least in my case it is correct in this way... so you propose to do something like $request->getSession()->remove('_security_main');?

Copy link
Member

Choose a reason for hiding this comment

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

yes. Your implementation is really destructive and has many side-effects on user-land code.

A solution to improve it could be to add a hook to allow adding some logic here (like the LogoutHandler for the logout)

@snc
Copy link
Contributor Author

snc commented Nov 1, 2011

@stof I have changed the code so that it only removes the token... do we still need any hook support?

@stof
Copy link
Member

stof commented Nov 1, 2011

well, the hook is for your own use case but it would be for 2.1 only anyway, not for 2.0

@@ -158,6 +160,12 @@ class ExceptionListener

$this->setTargetPath($request);

if ($authException instanceof AccountStatusException && ($token = $this->context->getToken()) instanceof UsernamePasswordToken) {
Copy link
Member

Choose a reason for hiding this comment

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

Why restricting this behavior to UsernamePasswordToken tokens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's because the issue should only occur if the firewall tries to reload the user and this can only be done if there is a username.

Copy link
Member

Choose a reason for hiding this comment

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

@snc all token contain a user and all listeners reload the user (a listener not doing it would be an issue if an admin locked the user for instance, and thus it would be a detached Doctrine entity causing many WTF).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stof I rechecked why I used UsernamePasswordToken, it is the parent class which contains the providerKey which is needed to get the name of the session variable.

@snc
Copy link
Contributor Author

snc commented Nov 7, 2011

Now that #2414 is merged to 2.1, this could be simplified for the master branch...

@snc snc mentioned this pull request Nov 10, 2011
fabpot added a commit that referenced this pull request Nov 10, 2011
Commits
-------

f9befb6 Remove only the security token instead of the session cookie.
348bccb Clear session cookie if user was deleted, is disabled or locked to prevent infinite redirect loops to the login path (fixes #1798).

Discussion
----------

Fix for issue 1798

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes

Clear session cookie if user was deleted, is disabled or locked to prevent infinite redirect loops to the login path (fixes #1798).

---------------------------------------------------------------------------

by snc at 2011/11/01 04:01:49 -0700

@stof I have changed the code so that it only removes the token... do we still need any hook support?

---------------------------------------------------------------------------

by stof at 2011/11/01 04:07:17 -0700

well, the hook is for your own use case but it would be for 2.1 only anyway, not for 2.0

---------------------------------------------------------------------------

by snc at 2011/11/07 15:11:52 -0800

Now that #2414 is merged to 2.1, this could be simplified for the master branch...
@fabpot fabpot merged commit f9befb6 into symfony:2.0 Nov 10, 2011
fabpot added a commit that referenced this pull request Nov 10, 2011
Commits
-------

4d80ebd Remove security token if user was deleted, is disabled or locked to prevent infinite redirect loops to the login path (fixes #1798).

Discussion
----------

[2.1] Fix for issue 1798

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #1798

This is a simplified PR of #2528 for the master branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants