I\'m trying to learn Spring security currently. I used BCryptPasswordEncoder
to encode user password before persisting into a database
Code:
Unsure if it is what you're after but a little cheap workaround I used so I didn't have to worry about encoding my database yet was
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
DataSource dataSource;
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource)
.usersByUsernameQuery("select username,CONCAT('{noop}',password),true from
public.\"Users\" where username=?")
.authoritiesByUsernameQuery("select username,role from public.\"Users\" where
username=?");
}
...
Note instead of grabbing the password I am concatenating it with {noop} first to tell the system to not use encoding.
Probably a sin but it works for now.