Unable to build with Javascript Authentication Provider
timbilt opened this issue · 1 comments
Describe the bug
After adding Javascript Provider jar to the providers folder, calling kc.sh build results in an error.
Version
17.0.0
Expected behavior
Keycloak should build successfully
Actual behavior
kc.sh build results in the following error:
` => ERROR [builder2 4/4] RUN /opt/keycloak/bin/kc.sh build 4.6s
[builder2 4/4] RUN /opt/keycloak/bin/kc.sh build:
#9 1.001 Updating the configuration and installing your custom providers, if any. Please wait.
#9 4.484 ERROR: Failed to run 'build' command.
#9 4.484 ERROR: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
#9 4.484 [error]: Build step org.keycloak.quarkus.deployment.KeycloakProcessor#configureProviders threw an exception: java.lang.NullPointerException: entry
#9 4.484 at java.base/java.util.Objects.requireNonNull(Objects.java:246)
#9 4.484 at java.base/java.util.zip.ZipFile.getInputStream(ZipFile.java:373)
#9 4.484 at java.base/java.util.jar.JarFile.getInputStream(JarFile.java:849)
#9 4.484 at org.keycloak.quarkus.deployment.KeycloakProcessor.createDeployableScriptProvider(KeycloakProcessor.java:535)
#9 4.484 at org.keycloak.quarkus.deployment.KeycloakProcessor.loadDeployedScriptProviders(KeycloakProcessor.java:510)
#9 4.484 at org.keycloak.quarkus.deployment.KeycloakProcessor.loadFactories(KeycloakProcessor.java:457)
#9 4.484 at org.keycloak.quarkus.deployment.KeycloakProcessor.configureProviders(KeycloakProcessor.java:254)
#9 4.484 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
#9 4.484 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
#9 4.484 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
#9 4.484 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
#9 4.484 at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:882)
#9 4.484 at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
#9 4.484 at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
#9 4.484 at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
#9 4.484 at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
#9 4.484 at java.base/java.lang.Thread.run(Thread.java:829)
#9 4.484 at org.jboss.threads.JBossThread.run(JBossThread.java:501)
#9 4.484
#9 4.484 ERROR: Build failure: Build failed due to errors
#9 4.484 [error]: Build step org.keycloak.quarkus.deployment.KeycloakProcessor#configureProviders threw an exception: java.lang.NullPointerException: entry
#9 4.484 at java.base/java.util.Objects.requireNonNull(Objects.java:246)
#9 4.484 at java.base/java.util.zip.ZipFile.getInputStream(ZipFile.java:373)
#9 4.484 at java.base/java.util.jar.JarFile.getInputStream(JarFile.java:849)
#9 4.484 at org.keycloak.quarkus.deployment.KeycloakProcessor.createDeployableScriptProvider(KeycloakProcessor.java:535)
#9 4.484 at org.keycloak.quarkus.deployment.KeycloakProcessor.loadDeployedScriptProviders(KeycloakProcessor.java:510)
#9 4.484 at org.keycloak.quarkus.deployment.KeycloakProcessor.loadFactories(KeycloakProcessor.java:457)
#9 4.484 at org.keycloak.quarkus.deployment.KeycloakProcessor.configureProviders(KeycloakProcessor.java:254)
#9 4.484 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
#9 4.484 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
#9 4.484 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
#9 4.484 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
#9 4.484 at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
#9 4.484 at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
#9 4.484 at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
#9 4.484 at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
#9 4.484 at java.base/java.lang.Thread.run(Thread.java:829)
#9 4.484 at org.jboss.threads.JBossThread.run(JBossThread.java:501)
#9 4.484
#9 4.485 ERROR: entry
#9 4.485 For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.
executor failed running [/bin/sh -c /opt/keycloak/bin/kc.sh build]: exit code: 1`
How to Reproduce?
Run this docker script with a Javascript Provider jar (specified as JavascriptAuthenticator here):
`FROM quay.io/keycloak/keycloak:17.0.0 as builder
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=token-exchange,scripts
ENV KC_DB=postgres
RUN /opt/keycloak/bin/kc.sh build
FROM quay.io/keycloak/keycloak:17.0.0 as builder2
COPY --from=builder /opt/keycloak/lib/quarkus/ /opt/keycloak/lib/quarkus/
COPY ./authenticator/package/JavascriptAuthenticator.jar /opt/keycloak/providers/
RUN /opt/keycloak/bin/kc.sh build
FROM quay.io/keycloak/keycloak:17.0.0
COPY --from=builder2 /opt/keycloak/lib/quarkus/ /opt/keycloak/lib/quarkus/
COPY --from=builder2 /opt/keycloak/providers /opt/keycloak/providers
WORKDIR /opt/keycloak
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start"]`
Anything else?
No response
The issue was that in the manifest json inside the jar, the path to the script \mypath\script.js was not understood. I guess because I build the jar on Windows. I just moved the script to the main directory in the jar and got rid of the path.