Skip to content

Conversation

@chalasr
Copy link
Member

@chalasr chalasr commented May 13, 2023

Q A
Branch? 6.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #50310
License MIT
Doc PR -

Not targeting 5.4 LTS as the bug is only breaking on 6.3 although it does exist on prior versions.


public function onLogout(LogoutEvent $event): void
{
if ($this->csrfTokenStorage instanceof SessionTokenStorage && !$event->getRequest()->hasPreviousSession()) {
Copy link
Member

Choose a reason for hiding this comment

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

What about fixing it in SessionTokenStorage instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Using SessionTokenStorage without a session has been deprecated in 5.x:

public function clear()
{
$session = $this->getSession();
foreach (array_keys($session->all()) as $key) {
if (str_starts_with($key, $this->namespace.'/')) {
$session->remove($key);
}
}
}
/**
* @throws SessionNotFoundException
*/
private function getSession(): SessionInterface

Ideally this listener shouldn't be registered for stateless firewalls, problem is that it's not a per-firewall listener but a global one. We should probably change that in another (feature) PR.

@nicolas-grekas
Copy link
Member

Any way to test this?

@nicolas-grekas
Copy link
Member

Thank you @chalasr.

@nicolas-grekas nicolas-grekas merged commit 684fdd2 into symfony:6.2 May 19, 2023
@chalasr
Copy link
Member Author

chalasr commented May 19, 2023

Any way to test this?

Sure, at least something preventing regressions. I'll do!

@chalasr chalasr deleted the skip-csrfclear-stateless branch May 19, 2023 16:00
chalasr added a commit that referenced this pull request May 19, 2023
…tateless logout (chalasr)

This PR was merged into the 6.2 branch.

Discussion
----------

[Security] Test `CsrfTokenClearingLogoutListener` with stateless logout

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | #50312 (comment)
| License       | MIT
| Doc PR        | -

Commits
-------

099ba75 [Security] Test `CsrfTokenClearingLogoutListener` with stateless logout
This was referenced May 22, 2023
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.

4 participants