-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Security] Make Login Rate Limiter also case insensitive for non-ascii user identifiers #41173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| return [ | ||
| $this->globalFactory->create($request->getClientIp()), | ||
| $this->localFactory->create(strtolower($request->attributes->get(Security::LAST_USERNAME)).'-'.$request->getClientIp()), | ||
| $this->localFactory->create(mb_strtolower($request->attributes->get(Security::LAST_USERNAME)).'-'.$request->getClientIp()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not rely on the global php.ini config
this should instead be:
\function_exists('mb_strtolower') && preg_match('//u', $v) ? mb_strtolower($v, 'UTF-8') : strtolower($v);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need function_exists('mb_strtolower')? The polyfill should make sure that the method exists, shouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@derrabus that's my understanding too.
@nicolas-grekas are you sure about passing 'UTF-8'? I don't mind changing, but seeing as utf-8 has been the default for a while, and if someone explicitly sets it to something else I'd assume they have a good reason and maybe it makes sense to follow their setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, about function_exists
for the ini setting, I think the code base is decoupled from it and we always use that kind of calls.
no global state rulez :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok done.. I kept the preg_match() guard, not sure if it's really needed or not? Is the polyfill not enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's needed yes :)
…i user identifiers
|
Thank you Jordi. |
As per discussion in #41156