Skip to content

Commit 67d9119

Browse files
committed
BouncyCastle Migration
Since `BouncyCastle 1.61` Argon2 password hashing is provided. Module is now using JAR packaging again, since `BouncyCastle 1.62` is provided in Keycloak, thus we don't need external dependencies. Refactored tests as well. Hashes created with V1.x of this provider should still be compatible.
1 parent 1c66e9d commit 67d9119

26 files changed

+711
-442
lines changed

README.md

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,46 @@
11
# Introduction
2-
This project introduces Argon2 Password Hashing for Keycloak (version 8.0.0 and above), it uses `de.mkammerer.argon2` as the library, more can be found on the [GitHub Project](https://github.com/phxql/argon2-jvm).
2+
This project introduces Argon2 Password Hashing for Keycloak, there are 2 versions:
3+
* V1.x, which uses `de.mkammerer.argon2` as the library, more can be found on the [GitHub Project](https://github.com/phxql/argon2-jvm). (Compatible with Keycloak V8.x and above)
4+
* V2.x, which inherits Keycloak's [BouncyCastle V1.62](https://www.bouncycastle.org/releasenotes.html#1.61) with native support for Argon2 (Compatible with Keycloak V10.x and above only)
35

4-
It generates an EAR which can be deployed using [Keycloak Deployer](https://www.keycloak.org/docs/latest/server_development/index.html#using-the-keycloak-deployer).
6+
V1.x is packaged as an EAR due to external dependencies. I will no longer maintain this version. Choose this one if you don't Keycloak V10.x or above.
7+
8+
V2.x is packaged as a JAR since it uses Keycloak's provided libraries. This will be the **actively maintained** version for now.
9+
10+
Both are deployed using [Keycloak Deployer](https://www.keycloak.org/docs/latest/server_development/index.html#using-the-keycloak-deployer).
511

612
# Build
713
Build the project using:
814
```
9-
mvn clean install;
15+
mvn clean package;
1016
```
1117

12-
This will build both the `jar-module` and `ear-module`:
18+
This will build the provider JAR:
1319
```
14-
[INFO] Reactor Summary for Argon2 Password Hash Provider x.y.z:
15-
[INFO]
16-
[INFO] Argon2 Password Hash Provider ...................... SUCCESS [ 0.633 s]
17-
[INFO] Argon2 Password Hash Provider Module ............... SUCCESS [ 3.264 s]
18-
[INFO] Argon2 Password Hash Provider Bundle ............... SUCCESS [ 0.348 s]
20+
[INFO] ----------< be.cronos.keycloak:argon2-password-hash-provider >----------
21+
[INFO] Building Argon2 Password Hash Provider 2.x.x
22+
[INFO] --------------------------------[ jar ]---------------------------------
1923
```
2024

2125
# Installation
22-
The EAR will contain all the necessary dependencies, therefore you can hot-deploy the module without additional configuration:
23-
```
24-
cp ear-module/target/argon2-password-hash-provider-bundle-*.ear /opt/keycloak/standalone/deployments/;
26+
Simply hot-deploy the module:
2527
```
26-
27-
# System Dependencies
28-
When running Keycloak on CentOS 7 (or another EL7), install argon2 system library:
29-
```
30-
yum install -y epel-release;
31-
yum install -y argon2;
28+
cp target/argon2-password-hash-provider-*.jar /opt/keycloak/standalone/deployments/argon2-password-hash-provider.jar;
3229
```
3330

34-
Once this is complete, start Keycloak.
35-
3631
# Keycloak configuration
3732
Finally, in the Keycloak realm of your choosing, activate the Argon2 password hashing via:
3833
`Authentication > Password Policy` and then selecting the policy `Hashing Algorithm` and name it: `argon2`.
3934

4035
Further tuning can be done by the other Policy Providers:
41-
* `Argon2 Variant` --> you can choose which Argon2 variant to use, either: ARGON2i, ARGON2d or ARGON2id
42-
* `Argon2 Iterations` --> tune the number of iterations the provider will perform
43-
* `Argon2 Memory Usage` --> tune the memory limitation of the provider
44-
* `Argon2 Parallelism` --> tune the number of threads and memory lanes
45-
* `Argon2 Salt Length` --> tune the length of the salt
46-
* `Argon2 Hash Length` --> tune the length of the hash
36+
* `Argon2 Version` --> you can choose which Argon2 version to use, either: `10` or `13` (default: 13)
37+
* `Argon2 Variant` --> you can choose which Argon2 variant to use, either: `ARGON2i`, `ARGON2d` or `ARGON2id` (default: ARGON2id)
38+
* `Argon2 Iterations` --> tune the number of iterations the provider will perform (default: 1)
39+
* `Argon2 Memory Usage` --> tune the memory limitation (in KB) of the provider (default: 65536)
40+
* `Argon2 Parallelism` --> tune the number of threads and memory lanes (default: 1)
41+
* `Argon2 Salt Length` --> tune the length of the salt (default: 16)
42+
* `Argon2 Hash Length` --> tune the length of the hash (default: 32)
4743

48-
For security purposes, there's also the possibility to configure the desired maximum runtime of the hashing, by default it's 1000 milliseconds, however it can be configured via the `Argon2 Max Time` policy.
49-
In case the hashing exceeds this time, it will generate a `WARN` in the console.
44+
> I have deprecated use of the `Argon2 Max Time` provider, as I believe it offers no real value. If you still have a use-case for this, let me know.
5045
51-
For parameter optimization, check the [project's benchmark](https://github.com/phxql/argon2-jvm#recommended-parameters) or the [Argon2 whitepaper recommendations](https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf#section.9).
46+
For parameter optimization, check the [Argon2 whitepaper recommendations](https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf#section.9).

ear-module/pom.xml

Lines changed: 0 additions & 43 deletions
This file was deleted.

jar-module/pom.xml

Lines changed: 0 additions & 51 deletions
This file was deleted.

jar-module/src/main/java/be/cronos/keycloak/credential/hash/Argon2PasswordHashProvider.java

Lines changed: 0 additions & 109 deletions
This file was deleted.

jar-module/src/main/java/be/cronos/keycloak/policy/Argon2VariantPasswordPolicyProviderFactory.java

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)