title: How to Register Keycloak Password Hash Service Provider SPI
body: <p><strong>Background</strong></p>
  
  <p>I need to migrate a user database for a bespoke app into Keycloak. I have created a <code>keycloak-add-user.json</code> file that imports the users successfully.  Migrated user passwords are hashed in the original system, however I've implemented a Keycloak Password Hash SPI service class that uses the existing algorithm to validate the hash and salt value of a migrated user. The Hash SPI class implements <code>PasswordHashProviderFactory</code> and <code>PasswordHashProvider</code> from the Keycloak SPI and is based on `Pbkdf2PasswordHashProvider'. </p>
  
  <pre><code>public class MyPasswordHashProvider implements PasswordHashProviderFactory, PasswordHashProvider {
  public static final String ID = "XXXX";
  </code></pre>
  
  <p><strong>The issue</strong></p>
  
  <p>When a migrated user tries to authenticate with keycloak an error is logged by <code>org.keycloak.hash.PasswordHashManager</code></p>
  
  <pre><code>Could not find hash provider XXXX for password
  </code></pre>
  
  <p>My jar contains an initialisation file <code>META-INF/services/org.keycloak.models.PasswordHashProviderFactory</code> with a single line containing the full classname of the HashProvider implementation.  </p>
  
  <pre><code>my.folder.MyPasswordHashProvider
  </code></pre>
  
  <p>This was based on the Federation SPI doco, but documentation for the Keycloak Password Hash SPI seems to be non-existent. What am I missing, or what do I need to do to register and use my Hash Provider with Keycloak?</p>