spring-projects / spring-projects/spring-security
PasswordEncoderFactories.createDelegatingPasswordEncoder() is not compatible with LdapShaPasswordEncoder
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Summary
PasswordEncoderFactories.createDelegatingPasswordEncoder() is creating wrong key for LdapShaPasswordEncoder(). Additionally, DelegatingPasswordEncoder removes the {SHA} prefix before call LdapShaPasswordEncoder.matches() that is expecting for it.
Actual Behavior
- PasswordEncoderFactories.createDelegatingPasswordEncoder() creates LdapShaPasswordEncoder() with key ldap but LdapShaPasswordEncoder() expects internally that encoded password starts with SHA or SSHA.
- LdapShaPasswordEncoder.matches() expectes that the encoded key is started by prefix {SHA} however DelegatingPasswordEncoder.matches() remove prefix before call LdapShaPasswordEncoder.
Expected Behavior
- LdapShaPasswordEncoder() must accept ldap as prefix or PasswordEncoderFactories.createDelegatingPasswordEncoder() instantiate LdapShaPasswordEncoder() with key SHA.
- DelegatingPasswordEncoder.matches() doesn't remove prefix or LdapShaPasswordEncoder() doesn't expect for it internally
Configuration
build.gradle
compile('org.springframework.boot:spring-boot-starter-data-ldap')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework:spring-jdbc')
compile('org.springframework.session:spring-session-core')
compile("org.springframework.ldap:spring-ldap-core")
compile("org.springframework.security:spring-security-ldap")
compile("org.springframework:spring-tx")
compile("com.unboundid:unboundid-ldapsdk")
code
DelegatingPasswordEncoder delegatingPasswordEncoder =
(DelegatingPasswordEncoder) PasswordEncoderFactories.createDelegatingPasswordEncoder();
delegatingPasswordEncoder.setDefaultPasswordEncoderForMatches(NoOpPasswordEncoder.getInstance());
Version
springBootVersion = '2.0.1.RELEASE'
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 tracing PasswordEncoderFactories.createDelegatingPasswordEncoder(), DelegatingPasswordEncoder.matches(), and LdapShaPasswordEncoder.matches() in the Spring Security source. Use the configuration in build.gradle to reproduce the LDAP encoder setup, then verify that the delegated prefix handling and LDAP SHA matching agree with the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100