11
11
12
12
namespace Symfony \Component \Security \Http \Firewall ;
13
13
14
- use Symfony \Component \Form \Extension \Csrf \CsrfProvider \CsrfProviderAdapter ;
15
- use Symfony \Component \Form \Extension \Csrf \CsrfProvider \CsrfProviderInterface ;
16
14
use Symfony \Component \HttpFoundation \Request ;
17
15
use Psr \Log \LoggerInterface ;
18
16
use Symfony \Component \Security \Csrf \CsrfToken ;
25
23
use Symfony \Component \Security \Core \Authentication \AuthenticationManagerInterface ;
26
24
use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
27
25
use Symfony \Component \Security \Core \Authentication \Token \UsernamePasswordToken ;
28
- use Symfony \Component \Security \Core \Exception \InvalidArgumentException ;
29
26
use Symfony \Component \Security \Core \Exception \InvalidCsrfTokenException ;
30
27
use Symfony \Component \Security \Core \Security ;
31
28
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
@@ -40,19 +37,13 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
40
37
{
41
38
private $ csrfTokenManager ;
42
39
43
- public function __construct (TokenStorageInterface $ tokenStorage , AuthenticationManagerInterface $ authenticationManager , SessionAuthenticationStrategyInterface $ sessionStrategy , HttpUtils $ httpUtils , $ providerKey , AuthenticationSuccessHandlerInterface $ successHandler , AuthenticationFailureHandlerInterface $ failureHandler , array $ options = array (), LoggerInterface $ logger = null , EventDispatcherInterface $ dispatcher = null , $ csrfTokenManager = null )
40
+ public function __construct (TokenStorageInterface $ tokenStorage , AuthenticationManagerInterface $ authenticationManager , SessionAuthenticationStrategyInterface $ sessionStrategy , HttpUtils $ httpUtils , $ providerKey , AuthenticationSuccessHandlerInterface $ successHandler , AuthenticationFailureHandlerInterface $ failureHandler , array $ options = array (), LoggerInterface $ logger = null , EventDispatcherInterface $ dispatcher = null , CsrfTokenManagerInterface $ csrfTokenManager = null )
44
41
{
45
- if ($ csrfTokenManager instanceof CsrfProviderInterface) {
46
- $ csrfTokenManager = new CsrfProviderAdapter ($ csrfTokenManager );
47
- } elseif (null !== $ csrfTokenManager && !$ csrfTokenManager instanceof CsrfTokenManagerInterface) {
48
- throw new InvalidArgumentException ('The CSRF token manager should be an instance of CsrfProviderInterface or CsrfTokenManagerInterface. ' );
49
- }
50
-
51
42
parent ::__construct ($ tokenStorage , $ authenticationManager , $ sessionStrategy , $ httpUtils , $ providerKey , $ successHandler , $ failureHandler , array_merge (array (
52
43
'username_parameter ' => '_username ' ,
53
44
'password_parameter ' => '_password ' ,
54
45
'csrf_parameter ' => '_csrf_token ' ,
55
- 'intention ' => 'authenticate ' ,
46
+ 'csrf_token_id ' => 'authenticate ' ,
56
47
'post_only ' => true ,
57
48
), $ options ), $ logger , $ dispatcher );
58
49
@@ -79,7 +70,7 @@ protected function attemptAuthentication(Request $request)
79
70
if (null !== $ this ->csrfTokenManager ) {
80
71
$ csrfToken = ParameterBagUtils::getRequestParameterValue ($ request , $ this ->options ['csrf_parameter ' ]);
81
72
82
- if (false === $ this ->csrfTokenManager ->isTokenValid (new CsrfToken ($ this ->options ['intention ' ], $ csrfToken ))) {
73
+ if (false === $ this ->csrfTokenManager ->isTokenValid (new CsrfToken ($ this ->options ['csrf_token_id ' ], $ csrfToken ))) {
83
74
throw new InvalidCsrfTokenException ('Invalid CSRF token. ' );
84
75
}
85
76
}
0 commit comments