thomasdarimont / keycloak-extension-playground

Simple project environment for creating custom Keycloak extensions
Apache License 2.0
648 stars 171 forks source link

How to build jar files #12

Closed niklashagman closed 4 years ago

niklashagman commented 4 years ago

Exciting extensions you have here! Am trying to get auth-check-authz-policy-extension to work. But I no nothing about how to create a jar file or java.

Here is how I create the jar file

git clone https://github.com/thomasdarimont/keycloak-extension-playground.git
#KC_VERSION=11.0.1
cd keycloak-extension-playground/auth-check-authz-policy-extension/src
jar cvf auth-check-authz-policy-extension/src/auth.jar .
chown keycloak:keycloak auth.jar
mv auth.jar $KEYCLOAK_STANDALONE/deployments/

Server seems OK

root@login:[~]: grep 'auth.jar' $KEYCLOAK_STANDALONE/log/server.log
2020-08-27 12:08:32,157 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "auth.jar" (runtime-name: "auth.jar")
2020-08-27 12:08:43,292 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 33) WFLYSRV0010: Deployed "auth.jar" (runtime-name : "auth.jar")

Keycloak started with following extra settings

root@login:[~]: grep 'sun.java.command' $KEYCLOAK_STANDALONE/log/server.log
sun.java.command = /opt/keycloak/jboss-modules.jar -mp /opt/keycloak/modules org.jboss.as.standalone -Djboss.home.dir=/opt/keycloak -Djboss.server.base.dir=/opt/keycloak/standalone -b 127.0.0.1 -Dkeycloak.profile=preview -Dkeycloak.profile.feature.scripts=enabled

Problem

I can not see anything new in the admin console panel. I guess I should see something new when doing Create Authenticator Execution and see the new extension Check Authz Policy.

niklashagman commented 4 years ago

A friend help me to solve how to build extensions.

$KEYCLOAK=/path/to/your/keycloak/standalone
git clone https://github.com/thomasdarimont/keycloak-extension-playground.git
cd keycloak-extension-playground/auth-check-authz-policy-extension

# I get failure if com.fasterxml is not removed from dependencies list
sed -i 's/\(.*\),com.fasterxml/\1/' pom.xml

mvn package
chown keycloak:keycloak target/*.jar
mv target/*.jar $KEYCLOAK/deployments/

Thumbs up if you like my advice! :slightly_smiling_face: