Skip to content
Advertisement

Keycloak custom PasswordHashProvider, salt change on each connection

I am trying to create a custom PasswordHashProvider. I succeeded in creating the component, the algorithm is working, the password saved in the database is correct.

A Salt is stored in a database, but I don’t understand how. I thought it was the base 64 salt, but it doesn’t match.

JavaScript

I add logs in the console when creating a password and when connecting a user. The salt is generated, stored, but the one retrieved during connection is different on each try.

When I register the user secret :

JavaScript

When I try to connect the user :

JavaScript

Does anyone know how salt is stored?

My class (for tests I force iterations to 5000) :

JavaScript

Advertisement

Answer

A Salt is stored in a database, but I don’t understand how. I thought it was the base 64 salt, but it doesn’t match.

It is based 64.

The salt is generated, stored, but the one retrieved during connection is different on each try.

The problem is this:

JavaScript

you are not print the actually content of the salt you are print the object “salt”.

Try instead:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement