-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Locked account produces "Invalid credentials" message #50028
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
Comments
Hey, thanks for your report! |
Yes this is still relevant. |
This is still relevant. The only workaround seems to be disabling the hide_user_not_found security setting and then checking the last authentication exception in the login controller and replacing a UserNotFoundException with a BadCredentials exception. This does seem to be brittle and better handled in the framework logic. security.yaml:
SecurityController.php:
|
Hey, thanks for your report! |
Hello? This issue is about to be closed if nobody replies. |
Can confirm the issue. This looks like a bug, because the |
Quoting #56830 (comment):
|
Thanks for posting here on this bug fix. Quoting #56830 (comment)
|
Symfony version(s) affected
5.4.21+
Description
When using the 'hide_user_not_found' feature (enabled by default), a user who tries to login with the proper credentials and has a locked or disabled account, will receive the "Invalid credentials" message. This is unexpected as the user is found, but the account is locked or disabled. The exception thrown for these cases are either the LockedException, DisabledException, or AccountExpiredException. One would expect this message only for a UsernameNotFoundException, not including cases where the user is found, but is inactive or locked out in some way. This used to provide useful feedback for our clients so they would not waste time trying to reset their password. I guess some could argue it is better to obfuscate the error in all cases, but this seems a bit paranoid, and again the feature seems improperly named. I would propose to either rename this or better yet, separate this into two features: e.g. hideUserNotFoundExceptions and hideAllAuthExceptions.
How to reproduce
Setup the application as normal. Implement a UserCheckerInterface on the main secured firewall. Throw an AccountStatusException in the checkPostAuth function. The exception can be the LockedException, DisabledException, or AccountExpiredException. Notice the message to the user is "Invalid (or Bad) credentials".
Possible Solution
Looking at the code in AuthenticatorManager#handleAuthenticationFailure:271 it does seem like a bug or at least a feature with a misleading name: hideUserNotFoundExceptions.
Replacing that conditional block with this made it work as expected and as previously:
I believe this block of code is also in a few other classes in the codebase, so this would also would be nice to address.
This is similar to this previously discussed here #42793, but has already been closed.
Additional Context
No response
The text was updated successfully, but these errors were encountered: