Exploring the PasswordEncoder interface
Password hashing in Spring Security is encapsulated and defined by implementations of the o.s.s.authentication.encoding.PasswordEncoder
interface. The simple configuration of a password encoder is possible through the createDelegatingPasswordEncoder()
method within the PasswordEncoderFactories
element, as follows:
//src/main/java/com/packtpub/springsecurity/configuration/SecurityConfig.java @Bean public PasswordEncoder encoder() { return PasswordEncoderFactories.createDelegatingPasswordEncoder(); }
You’ll be happy to learn that Spring Security ships with a number of implementations of passwordEncoder
, which are applicable for different needs and security requirements.
The following table provides a list of the out-of-the-box implementation classes and their benefits.
We can find the complete list of supported encoders in spring security in the Password
EncoderFactories
class. If one of these matches our...