diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5e5905e..e9df488 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -7,7 +7,7 @@ on: keycloak_bcrypt_version: description: Keycloak BCrypt version required: true - default: 1.5.0 + default: 1.5.1 name: Docker diff --git a/build.gradle.kts b/build.gradle.kts index 300a985..aeb1c78 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } group = "com.github.leroyguillaume" -version = "1.5.0" +version = "1.5.1" repositories { mavenCentral() diff --git a/src/main/java/com/github/leroyguillaume/keycloak/bcrypt/BCryptPasswordHashProvider.java b/src/main/java/com/github/leroyguillaume/keycloak/bcrypt/BCryptPasswordHashProvider.java index 6962a0f..312a441 100644 --- a/src/main/java/com/github/leroyguillaume/keycloak/bcrypt/BCryptPasswordHashProvider.java +++ b/src/main/java/com/github/leroyguillaume/keycloak/bcrypt/BCryptPasswordHashProvider.java @@ -38,9 +38,7 @@ public PasswordCredentialModel encodedCredential(final String rawPassword, final @Override public String encode(final String rawPassword, final int iterations) { final int cost = iterations == -1 ? defaultIterations : iterations; - final byte[] hash = BCrypt.with(BCrypt.Version.VERSION_2Y).hashToString(cost, rawPassword.toCharArray()) - .getBytes(); - return Base64.getEncoder().encodeToString(hash); + return BCrypt.with(BCrypt.Version.VERSION_2Y).hashToString(cost, rawPassword.toCharArray()); } @Override @@ -50,11 +48,8 @@ public void close() { @Override public boolean verify(final String rawPassword, final PasswordCredentialModel credential) { - final String base64EncodedHash = credential.getPasswordSecretData().getValue(); - final String base64DecodedHash = new String(Base64.getDecoder().decode(base64EncodedHash)); - - return BCrypt.verifyer(BCrypt.Version.VERSION_2Y) - .verify(rawPassword.toCharArray(), base64DecodedHash.toCharArray()) - .verified; + final String hash = credential.getPasswordSecretData().getValue(); + final BCrypt.Result verifier = BCrypt.verifyer().verify(rawPassword.toCharArray(), hash.toCharArray()); + return verifier.verified; } }