spring-projects / spring-projects/spring-security
SEC-2806: UserDetailsManager should know about the password encoder
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Mauro Molinari (Migrated from SEC-2806) said:
UserDetailsManager (in particular JdbcUserDetailsManager) has write methods that allow to write user (and password) information or change passwords on the backend repository (i.e. a database for JdbcUserDetailsManager).
The changePassword(String, String) method, for instance, takes the old and new passwords, tries to verify that the old password is correct and then writes the new password to the backend repository.
However, the way in which passwords are handled by a UserDetailsManager implementation is inconsistent: for instance in JdbcUserDetailsManager changePassword(String, String) calls org.springframework.security.authentication.AuthenticationManager.authenticate(Authentication) to verify the old password, so this means that the old password is expected to be not encoded (the actual encoding for comparison is performed by the AuthenticationManager), however then the new password is written as is to the database.
In other words, for this to work correctly, the calling code should pass the old password not encoded and the new one already encoded, which seems confusing and inconsistent to me.
IMHO the UserDetailsManager should have a passwordEncoder property that the user can set to specify which passwordEncoder should be used to write password information to the repository backend.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading UserDetailsManager and its JdbcUserDetailsManager implementation, especially changePassword(String, String), then trace how AuthenticationManager verifies the old password. Done should establish a consistent password-encoder configuration for writing new and changed passwords across the relevant UserDetailsManager implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, backend, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100