File tree 1 file changed +14
-2
lines changed
src/Symfony/Component/Security/Http/EventListener 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Security \Http \EventListener ;
13
13
14
+ use Symfony \Bundle \SecurityBundle \Security \FirewallMap ;
14
15
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
15
16
use Symfony \Component \Security \Csrf \TokenStorage \ClearableTokenStorageInterface ;
16
17
use Symfony \Component \Security \Csrf \TokenStorage \SessionTokenStorage ;
17
18
use Symfony \Component \Security \Http \Event \LogoutEvent ;
19
+ use Symfony \Component \Security \Http \FirewallMapInterface ;
18
20
19
21
/**
20
22
* @author Christian Flothmann <[email protected] >
24
26
class CsrfTokenClearingLogoutListener implements EventSubscriberInterface
25
27
{
26
28
private ClearableTokenStorageInterface $ csrfTokenStorage ;
29
+ private FirewallMapInterface $ map ;
27
30
28
- public function __construct (ClearableTokenStorageInterface $ csrfTokenStorage )
31
+ public function __construct (ClearableTokenStorageInterface $ csrfTokenStorage, FirewallMapInterface $ map )
29
32
{
30
33
$ this ->csrfTokenStorage = $ csrfTokenStorage ;
34
+ $ this ->map = $ map ;
31
35
}
32
36
33
37
public function onLogout (LogoutEvent $ event ): void
34
38
{
35
- if ($ this ->csrfTokenStorage instanceof SessionTokenStorage && !$ event ->getRequest ()->hasPreviousSession ()) {
39
+ $ request = $ event ->getRequest ();
40
+
41
+ if (
42
+ $ this ->csrfTokenStorage instanceof SessionTokenStorage
43
+ && (
44
+ ($ this ->map instanceof FirewallMap && $ this ->map ->getFirewallConfig ($ request )->isStateless ())
45
+ || !$ request ->hasPreviousSession ()
46
+ )
47
+ ) {
36
48
return ;
37
49
}
38
50
You can’t perform that action at this time.
0 commit comments