|
1 | 1 | # 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) |
3 | 5 |
|
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). |
5 | 11 |
|
6 | 12 | # Build |
7 | 13 | Build the project using: |
8 | 14 | ``` |
9 | | -mvn clean install; |
| 15 | +mvn clean package; |
10 | 16 | ``` |
11 | 17 |
|
12 | | -This will build both the `jar-module` and `ear-module`: |
| 18 | +This will build the provider JAR: |
13 | 19 | ``` |
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 ]--------------------------------- |
19 | 23 | ``` |
20 | 24 |
|
21 | 25 | # 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: |
25 | 27 | ``` |
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; |
32 | 29 | ``` |
33 | 30 |
|
34 | | -Once this is complete, start Keycloak. |
35 | | - |
36 | 31 | # Keycloak configuration |
37 | 32 | Finally, in the Keycloak realm of your choosing, activate the Argon2 password hashing via: |
38 | 33 | `Authentication > Password Policy` and then selecting the policy `Hashing Algorithm` and name it: `argon2`. |
39 | 34 |
|
40 | 35 | 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) |
47 | 43 |
|
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. |
50 | 45 |
|
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). |
0 commit comments