Skip to content

Commit d174191

Browse files
committed
EAR Packaging
Moved to EAR packaging strategy which allows third-party libraries, such as `de.mkammerer.argon2-jvm`, to be included in the package. This simplifies installation by not having to package a custom layer.
1 parent 6087d3c commit d174191

18 files changed

+120
-104
lines changed

README.md

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
# Dependencies
2-
This module depends on `de.mkammerer.argon2`, more can be found on the [GitHub Project](https://github.com/phxql/argon2-jvm).
1+
# Introduction
2+
This project introduces Argon2 Password Hashing for Keycloak, it uses `de.mkammerer.argon2` as the library, more can be found on the [GitHub Project](https://github.com/phxql/argon2-jvm).
33

4-
## Dependency installation
5-
Build the project once with `mvn install`, this will generate the `./target/jboss-modules/` directory, with two dependencies:
6-
* de.mkammerer.argon2-jvm
7-
* net.java.dev.jna
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).
85

9-
In your Keycloak installation, go to `./modules/` and modify the `layers.conf`:
6+
# Build
7+
Build the project using:
108
```
11-
layers=keycloak,custom
9+
mvn clean install;
1210
```
1311

14-
And create the directory in `./modules/`:
12+
This will build both the `jar-module` and `ear-module`:
1513
```
16-
mkdir -p ./modules/system/layers/custom;
14+
[INFO] Reactor Summary for Argon2 Password Hash Provider 9.0.0:
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]
1719
```
1820

19-
Now simply copy the 2 dependencies (generated in `./target/jboss-modules`) folders into the `custom` directory in Keycloak modules, e.g.:
21+
# Installation
22+
The EAR will contain all the necessary dependencies, therefore you can hot-deploy the module without additional configuration:
2023
```
21-
cp -R ./target/jboss-modules/de ./target/jboss-modules/net /opt/keycloak/modules/system/layers/custom/;
24+
cp ear-module/target/argon2-password-hash-provider-bundle-9.0.0.ear /opt/keycloak/standalone/deployments/;
2225
```
2326

2427
# System Dependencies
@@ -28,15 +31,7 @@ yum install -y epel-release;
2831
yum install -y argon2;
2932
```
3033

31-
Once this is complete, restart Keycloak.
32-
33-
# Provider deployment
34-
Once the dependencies are in order, the provider can be deployed by the [Keycloak Deployer](https://www.keycloak.org/docs/latest/server_development/index.html#using-the-keycloak-deployer), e.g.:
35-
```
36-
cp ./target/argon2-password-hash-provider-9.0.0.jar /opt/keycloak/standalone/deployments/;
37-
```
38-
39-
Keycloak will then load the provider when started (it also supports hot-deployments).
34+
Once this is complete, start Keycloak.
4035

4136
# Keycloak configuration
4237
Finally, in the Keycloak realm of your choosing, activate the Argon2 password hashing via:

ear-module/pom.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<name>Argon2 Password Hash Provider Bundle</name>
4+
<parent>
5+
<groupId>be.cronos.keycloak</groupId>
6+
<artifactId>argon2-password-hash-provider</artifactId>
7+
<version>9.0.0</version>
8+
</parent>
9+
<modelVersion>4.0.0</modelVersion>
10+
11+
<artifactId>argon2-password-hash-provider-bundle</artifactId>
12+
<packaging>ear</packaging>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>be.cronos.keycloak</groupId>
17+
<artifactId>argon2-password-hash-provider-module</artifactId>
18+
<version>${project.version}</version>
19+
</dependency>
20+
</dependencies>
21+
22+
<build>
23+
<plugins>
24+
<plugin>
25+
<groupId>org.apache.maven.plugins</groupId>
26+
<artifactId>maven-ear-plugin</artifactId>
27+
<configuration>
28+
<includeLibInApplicationXml>true</includeLibInApplicationXml>
29+
</configuration>
30+
</plugin>
31+
32+
<plugin>
33+
<groupId>org.wildfly.plugins</groupId>
34+
<artifactId>wildfly-maven-plugin</artifactId>
35+
<configuration>
36+
<skip>false</skip>
37+
</configuration>
38+
</plugin>
39+
40+
</plugins>
41+
</build>
42+
43+
</project>

jar-module/pom.xml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<name>Argon2 Password Hash Provider Module</name>
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>be.cronos.keycloak</groupId>
7+
<artifactId>argon2-password-hash-provider</artifactId>
8+
<version>9.0.0</version>
9+
</parent>
10+
11+
<artifactId>argon2-password-hash-provider-module</artifactId>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.keycloak</groupId>
16+
<artifactId>keycloak-core</artifactId>
17+
<scope>provided</scope>
18+
</dependency>
19+
<dependency>
20+
<groupId>org.keycloak</groupId>
21+
<artifactId>keycloak-server-spi</artifactId>
22+
<scope>provided</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.keycloak</groupId>
26+
<artifactId>keycloak-server-spi-private</artifactId>
27+
<scope>provided</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.keycloak</groupId>
31+
<artifactId>keycloak-services</artifactId>
32+
<scope>provided</scope>
33+
</dependency>
34+
<dependency>
35+
<groupId>de.mkammerer</groupId>
36+
<artifactId>argon2-jvm</artifactId>
37+
<version>${argon2jvm.version}</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>junit</groupId>
41+
<artifactId>junit</artifactId>
42+
</dependency>
43+
</dependencies>
44+
45+
</project>

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

File renamed without changes.

src/main/java/be/cronos/keycloak/credential/hash/Argon2PasswordHashProviderFactory.java renamed to jar-module/src/main/java/be/cronos/keycloak/credential/hash/Argon2PasswordHashProviderFactory.java

File renamed without changes.

src/main/java/be/cronos/keycloak/policy/Argon2HashLengthPasswordPolicyProviderFactory.java renamed to jar-module/src/main/java/be/cronos/keycloak/policy/Argon2HashLengthPasswordPolicyProviderFactory.java

File renamed without changes.

src/main/java/be/cronos/keycloak/policy/Argon2IterationsPasswordPolicyProviderFactory.java renamed to jar-module/src/main/java/be/cronos/keycloak/policy/Argon2IterationsPasswordPolicyProviderFactory.java

File renamed without changes.

src/main/java/be/cronos/keycloak/policy/Argon2MaxTimePasswordPolicyProviderFactory.java renamed to jar-module/src/main/java/be/cronos/keycloak/policy/Argon2MaxTimePasswordPolicyProviderFactory.java

File renamed without changes.

src/main/java/be/cronos/keycloak/policy/Argon2MemoryPasswordPolicyProviderFactory.java renamed to jar-module/src/main/java/be/cronos/keycloak/policy/Argon2MemoryPasswordPolicyProviderFactory.java

File renamed without changes.

src/main/java/be/cronos/keycloak/policy/Argon2ParallelismPasswordPolicyProviderFactory.java renamed to jar-module/src/main/java/be/cronos/keycloak/policy/Argon2ParallelismPasswordPolicyProviderFactory.java

File renamed without changes.

0 commit comments

Comments
 (0)