Skip to content

Commit 5c56326

Browse files
committed
[Security] Make Login Rate Limiter also case insensitive for non-ascii user identifiers
1 parent eb86bcf commit 5c56326

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

RateLimiter/DefaultLoginRateLimiter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ public function __construct(RateLimiterFactory $globalFactory, RateLimiterFactor
3939

4040
protected function getLimiters(Request $request): array
4141
{
42+
$username = $request->attributes->get(Security::LAST_USERNAME);
43+
$username = preg_match('//u', $username) ? mb_strtolower($username, 'UTF-8') : strtolower($username);
44+
4245
return [
4346
$this->globalFactory->create($request->getClientIp()),
44-
$this->localFactory->create(strtolower($request->attributes->get(Security::LAST_USERNAME)).'-'.$request->getClientIp()),
47+
$this->localFactory->create($username.'-'.$request->getClientIp()),
4548
];
4649
}
4750
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"symfony/security-core": "^5.2",
2222
"symfony/http-foundation": "^5.2",
2323
"symfony/http-kernel": "^5.2",
24+
"symfony/polyfill-mbstring": "~1.0",
2425
"symfony/polyfill-php80": "^1.15",
2526
"symfony/property-access": "^4.4|^5.0"
2627
},

0 commit comments

Comments
 (0)