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

Skip to content

[Security] Call logout handlers even if token is null #24769

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 1 commit into from
Closed

[Security] Call logout handlers even if token is null #24769

wants to merge 1 commit into from

Conversation

MatTheCat
Copy link
Contributor

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? yes
Deprecations? no
Tests pass? yes
Fixed tickets #7104
License MIT

My previous attempt to fix #7104 without any BC break was quite ugly so here we are.

As said before the logout handlers are currently not invoked if the security token is null. Problem is, the firewall listeners registration order only allows ContextListener to set a token before LogoutListener. This means any stateless firewall cannot benefit from the logout option, which is quite ironic as we have a CookieClearingLogoutHandler.

None of the Symfony logout handlers use logout's $token parameter so I thought about removing it but in the meantime I just allowed it to be null in order to mitigate possible BC breaks.

I really would like this to be fixed with Symfony 4!

@@ -27,5 +27,5 @@
* to be logged out. Usually, you would unset session variables, or remove
* cookies, etc.
*/
public function logout(Request $request, Response $response, TokenInterface $token);
public function logout(Request $request, Response $response, TokenInterface $token = null);
Copy link
Member

Choose a reason for hiding this comment

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

That would fatally break any existing logout handler, not doable.
Although it's not very sexy, passing a dummy token is better as it doesn't break (I would not call it DummyToken though, we need a meaningful name), and it seems to be the best alternative we have for fixing this bug.

Copy link
Member

Choose a reason for hiding this comment

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

Please don't close :) While it aims to achieve the same goal, it's fine to rework a PR.

Copy link
Contributor Author

@MatTheCat MatTheCat Oct 31, 2017

Choose a reason for hiding this comment

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

I thought we could have BC breaks between major versions? That's why I closed #24489 which was based on 2.7

Copy link
Member

Choose a reason for hiding this comment

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

Not without proper upgrade path, i.e. noticing about the breaking change, that is not possible from an interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I presume it's too late for an upgrade path now?

@linaori
Copy link
Contributor

linaori commented Nov 1, 2017

There will be a lot of code that makes assumptions of always having a valid & authenticated token in here. I think this will be a BC break with behavior that people have not anticipated due to those assumptions, and can potentially break a lot. Would require a carefully crafted BC layer. If it's a bug fix, you might be able to get it in, but it seems to be a new feature, which requires a very clear notice about the changes in behavior (and possibly won't make it into 3.4).

@MatTheCat
Copy link
Contributor Author

Well I opened this PR and #24489 in order to have a quick fix for 3.4 or 4.0 but if it's not possible I'll try to fix the root issue which is the listeners registration order.

@MatTheCat MatTheCat closed this Nov 3, 2017
@MatTheCat MatTheCat deleted the ticket_7104 branch November 3, 2017 08:37
@ebuildy
Copy link
Contributor

ebuildy commented Dec 21, 2017

What about create a dummy Token if $token is null?

@MatTheCat
Copy link
Contributor Author

@ebuildy #24805 is the current attempt.

@ebuildy
Copy link
Contributor

ebuildy commented Dec 22, 2017

Thanks you very much for your work, I hope this one will be merged. I must release a project tonight and find a quick/dirty workaround, do you have any recommandation? thanks you.

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.

[Security] Strange behaviour of Symfony\Component\Security\Http\Firewall\LogoutListener
5 participants