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 ?

  • This question would be better off in StackOverflow, there's probably 100x the number of people there who use Spring Secuirty often. – Daisetsu 2 hours ago

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.