I am using Spring Security. I want to store salt values for each and every user in the database.
Here is my database
User
-id
-username
-password
-salt
On accessing a particular URL, the default login form will be displayed.
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/userHomePage").authenticated().and().formLogin()
.and().exceptionHandling().accessDeniedPage("/Access_Denied");
}
Here is my Java code.
public class SecurityCheck extends WebSecurityConfigurerAdapter{
@Autowired
private DataSource dataSource;
private String usernameSearch="select username,password,account_status from user where username=?";
private String roleSearch="select username,usertype from user where username=?";
@Autowired
private RequestHandler requestHandler;
@Override
protected void configure(AuthenticationManagerBuilder authenticate)
throws Exception {
authenticate.jdbcAuthentication().dataSource(dataSource).usersByUsernameQuery(usernameSearch).
authoritiesByUsernameQuery(roleSearch);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/userHomePage").authenticated().and().formLogin()
.and().exceptionHandling().accessDeniedPage("/Access_Denied");
}
}
My question is, what changes should I make for achieving the results ? How do I first fetch the salt for that particular user and use in the authenticationManagerBuilder? OR any other way to do it ?