8000 bug #41156 [Security] Make Login Rate Limiter case insensitive (jderu… · symfony/symfony@1ba1305 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ba1305

Browse files
committed
bug #41156 [Security] Make Login Rate Limiter case insensitive (jderusse)
This PR was merged into the 5.2 branch. Discussion ---------- [Security] Make Login Rate Limiter case insensitive | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Login RateLimiter is case sensitive, while most login forms aren't case sensitive. This PR makes `DefaultLoginRateLimiter` case insensitive. Commits ------- c333f3d Make LoginRateLimiter case insentive
2 parents 7c43648 + c333f3d commit 1ba1305

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Symfony/Component/Security/Http/RateLimiter/DefaultLoginRateLimiter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function getLimiters(Request $request): array
4141
{
4242
return [
4343
$this->globalFactory->create($request->getClientIp()),
44-
$this->localFactory->create($request->attributes->get(Security::LAST_USERNAME).'-'.$request->getClientIp()),
44+
$this->localFactory->create(strtolower($request->attributes->get(Security::LAST_USERNAME)).'-'.$request->getClientIp()),
4545
];
4646
}
4747
}

src/Symfony/Component/Security/Http/Tests/EventListener/LoginThrottlingListenerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ public function testPreventsLoginWhenOverLocalThreshold()
7373
$this->listener->checkPassport($this->createCheckPassportEvent($passport));
7474
}
7575

76+
public function testPreventsLoginWithMultipleCase()
77+
{
78+
$request = $this->createRequest();
79+
$passports = [$this->createPassport('wouter'), $this->createPassport('Wouter'), $this->createPassport('wOuter')];
80+
81+
$this->requestStack->push($request);
82+
83+
for ($i = 0; $i < 3; ++$i) {
84+
$this->listener->checkPassport($this->createCheckPassportEvent($passports[$i % 3]));
85+
}
86+
87+
$this->expectException(TooManyLoginAttemptsAuthenticationException::class);
88+
$this->listener->checkPassport($this->createCheckPassportEvent($passports[0]));
89+
}
90+
7691
public function testPreventsLoginWhenOverGlobalThreshold()
7792
{
7893
$request = $this->createRequest();

0 commit comments

Comments
 (0)
0