Stuck at building a provider source code

A developer wrote us a provider. This provider enables us to log in users using their phone number plus an OTP.

For some reason, he did not support us anymore. Now we want to build it and use it.

The point is that we’re stuck at just building it. We installed JDK 17 on a machine based on what the docs say and used the ./mvnw at the root of the project. But we can’t build our provider.

We tried to get help from the Keycloak team:

But we got no answer.

So, we had an idea. We wanted to build the example provider that is authored by the Keycloak team:

We managed to create a Dockerfile that builds the entire source code:

FROM amd64/debian:bookworm-slim

RUN apt update -qq > /dev/null \
    && apt upgrade -qq > /dev/null \
    && apt install openjdk-17-jdk -qq -y > /dev/null \
    && apt install openjdk-17-jre -qq -y > /dev/null \
    && java -version \
    && echo 'export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))' >> /etc/bash.bashrc \
    && echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/bash.bashrc \
    && mkdir -p /temp > /dev/null \
    && chmod 777 --preserve-root /temp > /dev/null \
    && echo 'public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World from Java!"); } }' > /temp/Hello.java \
    && java /temp/Hello.java \
    && apt install git -y > /dev/null \
    && cd /temp \
    && git clone https://github.com/keycloak/keycloak \
    && cd /temp/keycloak \
    && ./mvnw clean install -DskipTests

WORKDIR /temp/keycloak

But it took a long time, and we can’t find the artifacts to use that authenticator.

So, we’re stuck at this point. We want to build a provider source code and use the resulting artifact (or Java package) to extend our Keycloak instance’s capabilities. How can we do that? Any help is appreciated.

This is probably one of the most convoluted attempts to build something, which makes following your steps and bug reports very tedious.

Skipping all of the needless steps in the dockerfile and compose use, when you build keycloak the final jar is located in examples/providers/authenticator/target/authenticator-required-action-example.jar
Be aware that these probably won’t work with 23.0.x, as the main branch is already on its way to 24.0.0 and has a lot of incompatible changes.

Just compiling the individual module won’t work because it has in-tree dependencies and compile won’t produce a jar, it just compiles the code.

1 Like

This is a cross-post of this Slack thread:

Thank you for the warning