11
11
12
12
namespace Symfony \Component \Security \Http \Firewall ;
13
13
14
- use Symfony \Component \Form \Extension \Csrf \CsrfProvider \CsrfProviderInterface ;
15
14
use Symfony \Component \HttpFoundation \Request ;
16
15
use Symfony \Component \HttpFoundation \Response ;
17
16
use Symfony \Component \HttpKernel \Event \GetResponseEvent ;
18
17
use Symfony \Component \Security \Core \SecurityContextInterface ;
19
18
use Symfony \Component \Security \Core \Exception \LogoutException ;
19
+ use Symfony \Component \Security \Csrf \CsrfTokenGeneratorInterface ;
20
20
use Symfony \Component \Security \Http \HttpUtils ;
21
21
use Symfony \Component \Security \Http \Logout \LogoutHandlerInterface ;
22
22
use Symfony \Component \Security \Http \Logout \LogoutSuccessHandlerInterface ;
@@ -34,18 +34,18 @@ class LogoutListener implements ListenerInterface
34
34
private $ handlers ;
35
35
private $ successHandler ;
36
36
private $ httpUtils ;
37
- private $ csrfProvider ;
37
+ private $ csrfTokenGenerator ;
38
38
39
39
/**
40
40
* Constructor
41
41
*
42
42
* @param SecurityContextInterface $securityContext
43
- * @param HttpUtils $httpUtils An HttpUtilsInterface instance
44
- * @param LogoutSuccessHandlerInterface $successHandler A LogoutSuccessHandlerInterface instance
45
- * @param array $options An array of options to process a logout attempt
46
- * @param CsrfProviderInterface $csrfProvider A CsrfProviderInterface instance
43
+ * @param HttpUtils $httpUtils An HttpUtilsInterface instance
44
+ * @param LogoutSuccessHandlerInterface $successHandler A LogoutSuccessHandlerInterface instance
45
+ * @param array $options An array of options to process a logout attempt
46
+ * @param CsrfTokenGeneratorInterface $csrfTokenGenerator A CsrfTokenGeneratorInterface instance
47
47
*/
48
- public function __construct (SecurityContextInterface $ securityContext , HttpUtils $ httpUtils , LogoutSuccessHandlerInterface $ successHandler , array $ options = array (), CsrfProviderInterface $ csrfProvider = null )
48
+ public function __construct (SecurityContextInterface $ securityContext , HttpUtils $ httpUtils , LogoutSuccessHandlerInterface $ successHandler , array $ options = array (), CsrfTokenGeneratorInterface $ csrfTokenGenerator = null )
49
49
{
50
50
$ this ->securityContext = $ securityContext ;
51
51
$ this ->httpUtils = $ httpUtils ;
@@ -55,7 +55,7 @@ public function __construct(SecurityContextInterface $securityContext, HttpUtils
55
55
'logout_path ' => '/logout ' ,
56
56
), $ options );
57
57
$ this ->successHandler = $ successHandler ;
58
- $ this ->csrfProvider = $ csrfProvider ;
58
+ $ this ->csrfTokenGenerator = $ csrfTokenGenerator ;
59
59
$ this ->handlers = array ();
60
60
}
61
61
@@ -72,7 +72,7 @@ public function addHandler(LogoutHandlerInterface $handler)
72
72
/**
73
73
* Performs the logout if requested
74
74
*
75
- * If a CsrfProviderInterface instance is available, it will be used to
75
+ * If a CsrfTokenGeneratorInterface instance is available, it will be used to
76
76
* validate the request.
77
77
*
78
78
* @param GetResponseEvent $event A GetResponseEvent instance
@@ -89,10 +89,10 @@ public function handle(GetResponseEvent $event)
89
89
return ;
90
90
}
91
91
92
- if (null !== $ this ->csrfProvider ) {
92
+ if (null !== $ this ->csrfTokenGenerator ) {
93
93
$ csrfToken = $ request ->get ($ this ->options ['csrf_parameter ' ], null , true );
94
94
95
- if (false === $ this ->csrfProvider ->isCsrfTokenValid ($ this ->options ['intention ' ], $ csrfToken )) {
95
+ if (false === $ this ->csrfTokenGenerator ->isCsrfTokenValid ($ this ->options ['intention ' ], $ csrfToken )) {
96
96
throw new LogoutException ('Invalid CSRF token. ' );
97
97
}
98
98
}
0 commit comments