File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \HttpFoundation \RateLimiter \AbstractRequestRateLimiter ;
15
15
use Symfony \Component \HttpFoundation \Request ;
16
- use Symfony \Component \RateLimiter \RateLimiter ;
16
+ use Symfony \Component \RateLimiter \RateLimiterFactory ;
17
17
use Symfony \Component \Security \Core \Security ;
18
18
19
19
/**
28
28
*/
29
29
final class DefaultLoginRateLimiter extends AbstractRequestRateLimiter
30
30
{
31
- private $ globalLimiter ;
32
- private $ localLimiter ;
31
+ private $ globalFactory ;
32
+ private $ localFactory ;
33
33
34
- public function __construct (RateLimiter $ globalLimiter , RateLimiter $ localLimiter )
34
+ public function __construct (RateLimiterFactory $ globalFactory , RateLimiterFactory $ localFactory )
35
35
{
36
- $ this ->globalLimiter = $ globalLimiter ;
37
- $ this ->localLimiter = $ localLimiter ;
36
+ $ this ->globalFactory = $ globalFactory ;
37
+ $ this ->localFactory = $ localFactory ;
38
38
}
39
39
40
40
protected function getLimiters (Request $ request ): array
41
41
{
42
42
return [
43
- $ this ->globalLimiter ->create ($ request ->getClientIp ()),
44
- $ this ->localLimiter ->create ($ request ->attributes ->get (Security::LAST_USERNAME ).$ request ->getClientIp ()),
43
+ $ this ->globalFactory ->create ($ request ->getClientIp ()),
44
+ $ this ->localFactory ->create ($ request ->attributes ->get (Security::LAST_USERNAME ).$ request ->getClientIp ()),
45
45
];
46
46
}
47
47
}
Original file line number Diff line number Diff line change 14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Component \HttpFoundation \Request ;
16
16
use Symfony \Component \HttpFoundation \RequestStack ;
17
- use Symfony \Component \RateLimiter \RateLimiter ;
17
+ use Symfony \Component \RateLimiter \RateLimiterFactory ;
18
18
use Symfony \Component \RateLimiter \Storage \InMemoryStorage ;
19
19
use Symfony \Component \Security \Core \Authentication \Token \TokenInterface ;
20
20
use Symfony \Component \Security \Core \Exception \TooManyLoginAttemptsAuthenticationException ;
@@ -35,13 +35,13 @@ protected function setUp(): void
35
35
{
36
36
$ this ->requestStack = new RequestStack ();
37
37
38
- $ localLimiter = new RateLimiter ([
38
+ $ localLimiter = new RateLimiterFactory ([
39
39
'id ' => 'login ' ,
40
40
'strategy ' => 'fixed_window ' ,
41
41
'limit ' => 3 ,
42
42
'interval ' => '1 minute ' ,
43
43
], new InMemoryStorage ());
44
- $ globalLimiter = new RateLimiter ([
44
+ $ globalLimiter = new RateLimiterFactory ([
45
45
'id ' => 'login ' ,
46
46
'strategy ' => 'fixed_window ' ,
47
47
'limit ' => 6 ,
You can’t perform that action at this time.
0 commit comments