title: User authentication in oauth2 with Spring Boot
body: <p>I have implemented OAuth 2.0 with spring boot. I am storing the hashed password (including a salt) into my database.</p>
  
  <p>I'm new to Spring and can't figure out how could I authenticate a username/password.</p>
  
  <p>This is my UserDAO class:</p>
  
  <pre><code>@Service
  public class UserDAO implements UserDetailsService{
  
  @Autowired
  private LoginDetailsManager loginDetailsManager;
  
  @Override
  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
  
      System.out.println("Get user");
      LoginDetails user = loginDetailsManager.getByUsername(username);
      System.out.println(user.toString());
      if (user == null) {
          // Not found...
          throw new UsernameNotFoundException(
                  "User " + username + " not found.");
      }
  
      GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("ROLE_USER");
      List&lt;GrantedAuthority&gt; grantedAuthorities = new ArrayList&lt;&gt;();
      grantedAuthorities.add(grantedAuthority);
  
      String password = user.getPasswordHash();
      String salt = user.getSalt();
      return new UserDetailsImpl(
              user.getUsername(),
              user.getPasswordHash(),
              salt,
              grantedAuthorities);
  }
  }
  </code></pre>
  
  <p>And this is the security configurer from the Application class:</p>
  
  <pre><code>@Override
  public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
      security.allowFormAuthenticationForClients();
  }
  </code></pre>
  
  <p>Questions:</p>
  
  <ol>
  <li>How to retrieve the password entered by the user? The implementation of UserDetailsService gives me the username entered by the user.</li>
  <li>Is there an in-built method to handle this "hashed password+salt" authentication? Am I getting it all wrong? </li>
  </ol>