Skip to content

Commit eb86bcf

Browse files
committed
Make LoginRateLimiter case insentive
1 parent a8b5ba8 commit eb86bcf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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
}

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)