Skip to content

SEC-1783: Can't tell the difference between no credentials and invalid credentials #2019

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

Closed
spring-projects-issues opened this issue Jul 13, 2011 · 2 comments
Labels
in: core An issue in spring-security-core status: declined A suggestion or change that we don't feel we should currently apply type: jira An issue that was migrated from JIRA

Comments

@spring-projects-issues
Copy link

Paul Benedict (Migrated from SEC-1783) said:

I need to record the number of password failures for existing users. DaoAuthenticationProvider#additionalAuthenticationChecks() is where I could do this, except BadCredentialsException is thrown for both (log messages) "no credentials provided" and "password does not match stored value". There's no way to distinguish the two at runtime. There's some refactoring here that could be done. Here are my suggestions:

  1. Subclass BadCredentialsException with new NoCredentialsException and InvalidCredentialsException
  2. Move the call to PasswordEncoder#isPasswordValid() to a new isPasswordValid() method whose default is to call the password encoder.

Of the two choices, I prefer #1

@spring-projects-issues
Copy link
Author

Paul Benedict said:

BTW, I grant I can subclass DaoAuthenticationProvider and check if UserDetails == null, but I'd rather defer directly to the superclass logic and catch a known exception.

@spring-projects-issues
Copy link
Author

Luke Taylor said:

I don't really see a good reason for introducing an additional exception to differentiate between an empty password and an invalid one. They would both normally be regarded as a failure.

An event listener would be a more appropriate way of recording authentication failures and gives you access to the Authentication token, so you can take whatever action you determine appropriate based on the entered authentication data.

@spring-projects-issues spring-projects-issues added in: core An issue in spring-security-core Closed status: declined A suggestion or change that we don't feel we should currently apply type: jira An issue that was migrated from JIRA labels Feb 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core status: declined A suggestion or change that we don't feel we should currently apply type: jira An issue that was migrated from JIRA
Projects
None yet
Development

No branches or pull requests

1 participant