Encoded password does not look like BCrypt
See original GitHub issueIs it just me or has anyone else got an error like o.s.s.c.bcrypt.BCryptPasswordEncoder : Encoded password does not look like BCrypt
?
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
CustomUserDetailsService customUserDetailsService;
.....
@Bean
public static PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(16);
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProvider());
}
@Bean
public DaoAuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
authenticationProvider.setUserDetailsService(customUserDetailsService);
authenticationProvider.setPasswordEncoder(passwordEncoder());
return authenticationProvider;
}
}
Service:
@Autowired
PasswordEncoder passwordEncoder;
user.setPassword(passwordEncoder.encode(user.getPassword()));
The encrypted password looks like $2a$16$AYSTH/JEPXPwqYBRswLq0emwmItvsQgf.dnaffXGJpvYML97bBoGe
in the db, but when I try to log in, I get the error.
P.s.: I am using this with OAuth2 Spring boot 5.0.4.RELEASE
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Encoded password does not look like BCrypt - Stack Overflow
The best way to identify this problem "Encoded password does not look like BCrypt" is setup a break porint in class ...
Read more >Encoded password does not look like Bcrypt - Spring
To fix the login issue and get rid of the warning “Encoded password does not look like BCrypt”, either remove the {bcrypt} prefix...
Read more >Spring Security : Encoded password does not look like BCrypt
A common mistake, the length of the “password” column (users table) is less than 60, for example, password VARCHAR(45) , and some databases...
Read more >Encrypted Password does not look like BCrypt | Spring Boot 2
Encrypted Password does not look like BCrypt | Spring Boot 2 | Spring Security 5 | Spring Cloud ...
Read more >[Solved]-Encoded password does not look like BCrypt
[Solved]-Encoded password does not look like BCrypt - spring security version is 5.3.2-Springboot ... You can specify the bcrypt version to use with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure. First, open your security configuration which extends
WebSecurityConfigurerAdapter
and paste below function:Then in the same configuration file, modify your
authenticationProvider()
function like this:Note: If you create multiple
PasswordEncoder
beans, the compiler will always select the first one. If you also need to implementNoOpPasswordEncoder
, do it in the file that you really need to use it and create it without@Bean
.In your service, or wherever you want to use you need to autowire the `PasswordEncoder`:
And you can encrypt your String like this: `passwordEncoder.encode("password");`
If you want to match a raw password with an encrypted one, you can do it with `passwordEncoder.matches("rawPassword", user.getPassword());` where `user.getPassword()` returns an encrypted password (from db).
Yes, I did. If you also have the same problem, you can follow here