I've made a simple restAPI with Spring-boot and spring security, implementing Basic Authentication. I want to use inMemoryAuthentication, and bcryptPasswordEncoder, but for some reason my compiler is looking for the passwordEncoder in the wrong place, See title vs security.crypto.password.PasswordEncoder.
In spring-security-config 4.x version in AbstractDaoAuthenticationConfigurer the passwordEncoder() is overloading both the org.springframework.security.crypto.password.PasswordEncoder and org.springframework.security.authentication.encoding.PasswordEncoder, where else in spring-security-config 5.x it is only the org.springframework.security.crypto.password.PasswordEncoder
download org.springframework.security.crypto
Download File
https://perhandcepne1981.blogspot.com/?cbg=2x0vCK
org.springframework.security.crypto.password.MessageDigestPasswordEncoder is also deprecated so we can go for org.springframework.security.crypto.password.DelegatingPasswordEncoder which can be used for different types of algorithm by default it uses bcrypt but supports ldap,MD4, MD5, noop,pbkdf2,scrypt,SHA-1,SHA-256,sha256.
Field bCryptPasswordEncoder in com.mahmut.demoemployee.application.dao.Imp.UserDaoImp required a bean of type 'org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder' that could not be found.
Could not find org.neo4j:neo4j-cypher-dsl:2.0.1.
Searched in the following locations:
-cypher-dsl/2.0.1/neo4j-cypher-dsl-2.0.1.pom
-cypher-dsl/2.0.1/neo4j-cypher-dsl-2.0.1.jar
Required by:
com.foo:ProjectX:1.0 > org.springframework.data:spring-data-neo4j:3.3.0.RELEASE
HTTP Status 500 - org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.UsersComponent': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.crypto.password.PasswordEncoder com.car.component.impl.UsersComponentImpl.passwordEncoder; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.crypto.password.PasswordEncoder] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: org.springframework.beans.factory.annotation.Autowired(required=true)
As of Spring Security 3.1.4.RELEASE, the old org.springframework.security.authentication.encoding.PasswordEncoder has been deprecated in favour of org.springframework.security.crypto.password.PasswordEncoder. As my application has not been released to the public yet, I decided to move to the new, not deprecated API.
The good thing is that Spring Security will do this for you. Spring Security 3.2 introduced the new org.springframework.security.crypto.password.PasswordEncoder interface and some implementations: BCryptPasswordEncoder, StandardPasswordEncoder (and NoOpPasswordEncoder).
Important: Do not confuse org.springframework.security.crypto.password.PasswordEncoder with the old deprecated org.springframework.security.authentication.encoding.PasswordEncoder
I recommend to use org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder.The BCryptPasswordEncoder (in contrast to the StandardPasswordEncoder) use an salt that is different for each password (but not global like the one from StandardPasswordEncoder). When you encode a raw password (public String encode(CharSequence rawPassword)) then the returned encoded password is not just the encoded password, it also contains some meta information about the used hash-algorithm, the used salt and of course the encoded password.
This class implements the Spring Security 4.x org.springframework.security.crypto.password.PasswordEncoder interface, allowing Spring Security-enabled applications to use JASYPT for password encryption.
This is the error that appears when I try to create a new user"message": "Cannot invoke \"org.springframework.security.crypto.password.PasswordEncoder.encode(java.lang.CharSequence)\" because \"this.passwordEncoder\" is null", "path": "/auth/nuevo"
35fe9a5643