Closed TilmeezUrRehmanBhatti closed 2 years ago
you can start out with the following:
since you are using formLogin Spring Security will BY DEFAULT set up most things for you, the only thing you need to provide is a password encoder, and an implementation of the UserDetailsService
both as Bean
this means the following you can fully remove the following code:
// authenticationProvider bean definition
@Bean
public DaoAuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider auth = new DaoAuthenticationProvider();
//set the custom employee details service
auth.setUserDetailsService(employeeService);
// set th password encoder
auth.setPasswordEncoder(passwordEncoder());
return auth;
}
Since you provide the UserDetailsServices
as a Bean
and a PasswordEncoder
as a Bean
Spring Security will build an AuthenticationProvider
for you.
@Tandolf I also try this i am still getting same error , if i debug it matches plan text with bcrypt password from database and that i am not understanding why. I don't think it's because of the password its somewhere in the code where we are not handling incoming passwords from the user to BCrypt and then matching, while debugging I noticed it try to match with the plain password with is entered by me(user) with BCrypt password from Database. And i don't know how to handle this or convert the input password to BCrypt because normally it's handled by spring security (If I am not wrong)
This issue is related to column size. As I am using Postgres, it might be of type issue.
https://mkyong.com/spring-security/spring-security-encoded-password-does-not-look-like-bcrypt/
Alter the password column type from char to varchar, it solves my problem
thank you for wasting others time.
When i am using Spring Security UserDetailsService i am encounter Encoded password does not look like BCrypt, whereas without it working f9
From EmployeeServiceImpl
from securityconfig.java