Configure Argon2's type correctly in Argon2PasswordHashProviderFactory

Closes #40232

Signed-off-by: Rutger Lubbers <RutgerLubbers@gmail.com>
This commit is contained in:
Rutger Lubbers
2025-06-04 15:47:07 +02:00
committed by GitHub
parent 0709878d2a
commit be330d3809

View File

@@ -30,7 +30,7 @@ public class Argon2PasswordHashProviderFactory implements PasswordHashProviderFa
* When we run more, this only leads to an increased memory usage and to throttling of the process in containerized environments * When we run more, this only leads to an increased memory usage and to throttling of the process in containerized environments
* when a CPU limit is imposed. The throttling would have a negative impact on other concurrent non-hashing activities of Keycloak. * when a CPU limit is imposed. The throttling would have a negative impact on other concurrent non-hashing activities of Keycloak.
*/ */
private Semaphore cpuCoreSempahore; private Semaphore cpuCoreSemaphore;
private String version; private String version;
private String type; private String type;
@@ -41,18 +41,18 @@ public class Argon2PasswordHashProviderFactory implements PasswordHashProviderFa
@Override @Override
public PasswordHashProvider create(KeycloakSession session) { public PasswordHashProvider create(KeycloakSession session) {
return new Argon2PasswordHashProvider(version, type, hashLength, memory, iterations, parallelism, cpuCoreSempahore); return new Argon2PasswordHashProvider(version, type, hashLength, memory, iterations, parallelism, cpuCoreSemaphore);
} }
@Override @Override
public void init(Config.Scope config) { public void init(Config.Scope config) {
version = config.get(VERSION_KEY, Argon2Parameters.DEFAULT_VERSION); version = config.get(VERSION_KEY, Argon2Parameters.DEFAULT_VERSION);
type = config.get(VERSION_KEY, Argon2Parameters.DEFAULT_TYPE); type = config.get(TYPE_KEY, Argon2Parameters.DEFAULT_TYPE);
hashLength = config.getInt(HASH_LENGTH_KEY, Argon2Parameters.DEFAULT_HASH_LENGTH); hashLength = config.getInt(HASH_LENGTH_KEY, Argon2Parameters.DEFAULT_HASH_LENGTH);
memory = config.getInt(MEMORY_KEY, Argon2Parameters.DEFAULT_MEMORY); memory = config.getInt(MEMORY_KEY, Argon2Parameters.DEFAULT_MEMORY);
iterations = config.getInt(ITERATIONS_KEY, Argon2Parameters.DEFAULT_ITERATIONS); iterations = config.getInt(ITERATIONS_KEY, Argon2Parameters.DEFAULT_ITERATIONS);
parallelism = config.getInt(PARALLELISM_KEY, Argon2Parameters.DEFAULT_PARALLELISM); parallelism = config.getInt(PARALLELISM_KEY, Argon2Parameters.DEFAULT_PARALLELISM);
cpuCoreSempahore = new Semaphore(config.getInt(CPU_CORES_KEY, Runtime.getRuntime().availableProcessors())); cpuCoreSemaphore = new Semaphore(config.getInt(CPU_CORES_KEY, Runtime.getRuntime().availableProcessors()));
} }
@Override @Override