use of org.springframework.security.crypto.password.DelegatingPasswordEncoder in project best-cloud by shanzhaozhen.
the class PasswordEncoderConfig method passwordEncoder.
@Bean
public PasswordEncoder passwordEncoder() {
PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
// 增加默认编码器
((DelegatingPasswordEncoder) passwordEncoder).setDefaultPasswordEncoderForMatches(new BCryptPasswordEncoder());
return passwordEncoder;
}
use of org.springframework.security.crypto.password.DelegatingPasswordEncoder in project jpsonic by tesshucom.
the class GlobalSecurityConfig method delegatingPasswordEncoder.
@Bean
public PasswordEncoder delegatingPasswordEncoder() {
// Spring Security 5 require storing the encoder id alongside the encoded password
// (e.g. "{md5}hash" for an MD5-encoded password hash), which differs from previous
// versions.
//
// Airsonic unfortunately stores passwords in plain-text, which is why we are setting
// the "no-op" (plain-text) password encoder as a default here. This default will be
// used when no encoder id is present.
//
// This means that legacy Airsonic passwords (stored simply as "password" in the db)
// will be matched like "{noop}password" and will be recognized successfully. In the
// future password encoding updates will be done here.
PasswordEncoder defaultEncoder = NoOpPasswordEncoder.getInstance();
String defaultIdForEncode = "noop";
Map<String, PasswordEncoder> encoders = LegacyMap.of(defaultIdForEncode, defaultEncoder);
DelegatingPasswordEncoder passworEncoder = new DelegatingPasswordEncoder(defaultIdForEncode, encoders);
passworEncoder.setDefaultPasswordEncoderForMatches(defaultEncoder);
return passworEncoder;
}
use of org.springframework.security.crypto.password.DelegatingPasswordEncoder in project Spring-5.0-Projects by PacktPublishing.
the class WebSecurityConfig method passwordEncoder.
@Bean
public PasswordEncoder passwordEncoder() {
Map<String, PasswordEncoder> encoders = new HashMap<>();
encoders.put(PwdEncodingAlgo.BCrypt.getStatus(), new BCryptPasswordEncoder());
encoders.put(PwdEncodingAlgo.Pbkf2.getStatus(), new Pbkdf2PasswordEncoder());
encoders.put(PwdEncodingAlgo.SCrypt.getStatus(), new SCryptPasswordEncoder());
return new DelegatingPasswordEncoder(PwdEncodingAlgo.BCrypt.getStatus(), encoders);
}
Aggregations