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 1313
1414use Symfony \Component \HttpFoundation \RateLimiter \AbstractRequestRateLimiter ;
1515use Symfony \Component \HttpFoundation \Request ;
16- use Symfony \Component \RateLimiter \RateLimiter ;
16+ use Symfony \Component \RateLimiter \RateLimiterFactory ;
1717use Symfony \Component \Security \Core \Security ;
1818
1919/**
2828 */
2929final class DefaultLoginRateLimiter extends AbstractRequestRateLimiter
3030{
31- private $ globalLimiter ;
32- private $ localLimiter ;
31+ private $ globalFactory ;
32+ private $ localFactory ;
3333
34- public function __construct (RateLimiter $ globalLimiter , RateLimiter $ localLimiter )
34+ public function __construct (RateLimiterFactory $ globalFactory , RateLimiterFactory $ localFactory )
3535 {
36- $ this ->globalLimiter = $ globalLimiter ;
37- $ this ->localLimiter = $ localLimiter ;
36+ $ this ->globalFactory = $ globalFactory ;
37+ $ this ->localFactory = $ localFactory ;
3838 }
3939
4040 protected function getLimiters (Request $ request ): array
4141 {
4242 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 ()),
4545 ];
4646 }
4747}
Original file line number Diff line number Diff line change 1414use PHPUnit \Framework \TestCase ;
1515use Symfony \Component \HttpFoundation \Request ;
1616use Symfony \Component \HttpFoundation \RequestStack ;
17- use Symfony \Component \RateLimiter \RateLimiter ;
17+ use Symfony \Component \RateLimiter \RateLimiterFactory ;
1818use Symfony \Component \RateLimiter \Storage \InMemoryStorage ;
1919use Symfony \Component \Security \Core \Authentication \Token \TokenInterface ;
2020use Symfony \Component \Security \Core \Exception \TooManyLoginAttemptsAuthenticationException ;
@@ -35,13 +35,13 @@ protected function setUp(): void
3535 {
3636 $ this ->requestStack = new RequestStack ();
3737
38- $ localLimiter = new RateLimiter ([
38+ $ localLimiter = new RateLimiterFactory ([
3939 'id ' => 'login ' ,
4040 'strategy ' => 'fixed_window ' ,
4141 'limit ' => 3 ,
4242 'interval ' => '1 minute ' ,
4343 ], new InMemoryStorage ());
44- $ globalLimiter = new RateLimiter ([
44+ $ globalLimiter = new RateLimiterFactory ([
4545 'id ' => 'login ' ,
4646 'strategy ' => 'fixed_window ' ,
4747 'limit ' => 6 ,
You can’t perform that action at this time.
0 commit comments