title: Spring Security Salt
body: <p>I'm trying to add a salt when adding a new user/pwd, but the docs seem to be missing how to do this.</p>
  
  <p>Here's a basic example:</p>
  
  <pre><code>&lt;authentication-manager&gt;
      &lt;authentication-provider user-service-ref="userDetailsService"&gt;
          &lt;password-encoder hash="md5"&gt;
              &lt;salt-source user-property="username"/&gt;
          &lt;/password-encoder&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  </code></pre>
  
  <p>You can see by the example that neither a custom salt or custom password encoder is used.</p>
  
  <p>So, how would I wire the Salt in when adding a new user/pwd?  I'd assume it would be something along the lines of:</p>
  
  <pre><code>@Autowired SaltSource saltSource;
  protected void foo(final CustomUser user) {
      final PasswordEncoder encoder = new Md5PasswordEncoder();
      user.setPassword(encoder.encodePassword(user.getPassword(), saltSource));
  }
  </code></pre>
  
  <p>However, since I am using the default salt/password encoders and I don't have a custom salt bean the autowire would fail.</p>
  
  <p>Any clue how to make this work?</p>