PasswordEncoder in spring security 5

 

1 {bcrypt}$2a$10$vCXMWCn7fDZWOcLnIEhmK.74dvK1Eh8ae2WrWlhr2ETPLoxQctN4.
2 {noop}plaintextpassword

 

1 @Bean
2 public PasswordEncoder passwordEncoder() {
3     return PasswordEncoderFactories.createDelegatingPasswordEncoder();
4 }

 

 1 public static PasswordEncoder createDelegatingPasswordEncoder() {
 2     String encodingId = "bcrypt";
 3     Map<String, PasswordEncoder> encoders = new HashMap<>();
 4     encoders.put(encodingId, new BCryptPasswordEncoder());
 5     encoders.put("ldap", new org.springframework.security.crypto.password.LdapShaPasswordEncoder());
 6     encoders.put("MD4", new org.springframework.security.crypto.password.Md4PasswordEncoder());
 7     encoders.put("MD5", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("MD5"));
 8     encoders.put("noop", org.springframework.security.crypto.password.NoOpPasswordEncoder.getInstance());
 9     encoders.put("pbkdf2", new Pbkdf2PasswordEncoder());
10     encoders.put("scrypt", new SCryptPasswordEncoder());
11     encoders.put("SHA-1", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-1"));
12     encoders.put("SHA-256", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-256"));
13     encoders.put("sha256", new org.springframework.security.crypto.password.StandardPasswordEncoder());
14 
15     return new DelegatingPasswordEncoder(encodingId, encoders);
16 }

 

https://blog.marcosbarbero.com/password-encoder-migration-spring-security-5/

posted @ 2020-09-07 11:58  北极熊129  阅读(246)  评论(0编辑  收藏  举报