# Trouble getting custom authentication script deployed - Docker 19.0.2

**URL:** <https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513>\
**Category:** Configuring the server\
**Tags:** authentication\
**Created:** [September 20, 2022, 9:53am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513 "2022-09-20T09:53:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![belerovon](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/belerovon/32/6390_2.png) [@belerovon](https://forum.keycloak.org/u/belerovon)\
**Post date:** [September 20, 2022, 9:53am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/1 "2022-09-20T09:53:16Z")

</div>

Hi all

I have a question to the feature “scripts” - I have enabled the feature in my Dockerfile and when I build it I found in logs “INFO [org.keycloak.common.Profile] (build-38) Preview feature enabled: scripts”

In the new Admin-GUI under enabled Feature I can see the Feature “scripts” is enabled.

But when I clone a Authentication Flow and want to add a “Authenticator Execution” I can not found in the provider List “Script” - not in the new or old admin GUI.

What I’ve done wrong?

---

<div class="post-metadata">

**Author:** ![mbonn](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/mbonn/32/5755_2.png) [@mbonn](https://forum.keycloak.org/u/mbonn)\
**Post date:** [September 21, 2022, 6:46am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/2 "2022-09-21T06:46:44Z")

</div>

Scripts have to be deployed to the server’s file system, packaged in a jar file:  
[https://www.keycloak.org/docs/latest/server\_development/index.html#\_script\_providers](https://www.keycloak.org/docs/latest/server_development/index.html#_script_providers)  
Then the authenticator appears with its name (the one you gave it in the keycloak-scripts.json file) in the provider list.

---

<div class="post-metadata">

**Author:** ![belerovon](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/belerovon/32/6390_2.png) [@belerovon](https://forum.keycloak.org/u/belerovon)\
**Post date:** [September 21, 2022, 3:01pm UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/3 "2022-09-21T15:01:59Z")

</div>

Hi @mbonn

get it.

Now I try to build a script - or better first want to import a script that I think was working with other - and used the Script here: [http://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed/15664](http://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed/15664)

Jar looks like:  
jar tf my-role-based-authenticator.jar

- META-INF/
- META-INF/MANIFEST.MF
- META-INF/keycloak-scripts.json
- my-role-based-authenticator.js

I linked it in docker-container to providers and set the user (key cloak:keycloak). Than I also rebuild the image (./kc.sh build).

But can not found the the script on providers (nor under Server Information \> Providers)

Could it be the script is not connect?  
Or any other clever hint from you? 😉

---

<div class="post-metadata">

**Author:** ![belerovon](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/belerovon/32/6390_2.png) [@belerovon](https://forum.keycloak.org/u/belerovon)\
**Post date:** [September 21, 2022, 3:06pm UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/4 "2022-09-21T15:06:53Z")

</div>

PS on “bin/kc.sh show-config” I can see:

kc.provider.file.my-role-based-authenticator.jar.last-modified = 1663758669402 (PersistedConfigSource)

So think in general the script should loaded.

---

<div class="post-metadata">

**Author:** ![mbonn](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/mbonn/32/5755_2.png) [@mbonn](https://forum.keycloak.org/u/mbonn)\
**Post date:** [September 22, 2022, 6:53am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/5 "2022-09-22T06:53:49Z")

</div>

Do you have any error or warning entires in your logs?  
What is the content of keycloak-scripts.json?  
Do you run a JDK version different from 11? (Script engine has to be manually added on newer Java versions…)?  
Have you tried a maximal simple authenticator (just doing a context.success() within the authenticate(…) method)?  
Or tried a primitive JS token mapper? Is that working?  
If you try without docker on a bare metal setup, is it working then?

---

<div class="post-metadata">

**Author:** ![belerovon](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/belerovon/32/6390_2.png) [@belerovon](https://forum.keycloak.org/u/belerovon)\
**Post date:** [September 23, 2022, 7:36am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/6 "2022-09-23T07:36:04Z")

</div>

My failure -  
I use a Dockerfile and build a custom docker Image.  
When I import a script and rebuild it will affect in this.  
When I import a script with the Dockerfile and build my container than it works.

---

<div class="post-metadata">

**Author:** ![mbonn](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/mbonn/32/5755_2.png) [@mbonn](https://forum.keycloak.org/u/mbonn)\
**Post date:** [September 23, 2022, 8:37am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/7 "2022-09-23T08:37:59Z")

</div>

Yeah, everything is so much easier with docker…

---

<div class="post-metadata">

**Author:** ![TafkaMax](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tafkamax/32/6796_2.png) [@TafkaMax](https://forum.keycloak.org/u/TafkaMax)\
**Post date:** [October 20, 2022, 9:10am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/8 "2022-10-20T09:10:55Z")

</div>

So you can’t use the base image from [quay.io](http://quay.io) and you have to build your own dockerfile?

So if the server says this:

> 2022-10-20 09:02:37,845 INFO [io.quarkus] (Shutdown thread) Keycloak stopped in 0.177s  
> Changes detected in configuration. Updating the server image.  
> Updating the configuration and installing your custom providers, if any. Please wait.  
> 2022-10-20 09:02:44,184 INFO [org.keycloak.common.Profile] (build-95) Preview feature enabled: scripts  
> 2022-10-20 09:02:50,643 INFO [io.quarkus.deployment.QuarkusAugmentor] (main) Quarkus augmentation completed in 8888ms  
> Server configuration updated and persisted. Run the following command to review the configuration:
> 
> kc.sh show-config
> 
> Next time you run the server, just run:
> 
> kc.sh start --optimized

Then its actually not doing what it is supposed to do “Installing your custom providers” and it needs to be done in the dockerfile? Geez.

* * *

EDIT: Same here, I can see the custom\_providers jar.

```auto
	kc.provider.file.custom_providers.jar.last-modified = 1666256440343 (PersistedConfigSource)

```

---

<div class="post-metadata">

**Author:** ![TafkaMax](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tafkamax/32/6796_2.png) [@TafkaMax](https://forum.keycloak.org/u/TafkaMax)\
**Post date:** [October 20, 2022, 10:22am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/9 "2022-10-20T10:22:40Z")

</div>

Weird, can’t seem to get it to work even with build…

```auto
FROM quay.io/keycloak/keycloak:19.0.3 as builder

WORKDIR /opt/keycloak
ENV KC_HEALTH_ENABLED=True
ENV KC_METRICS_ENABLED=True
ENV KC_FEATURES=authorization,account2,admin2,account-api,docker,impersonation,web-authn,client-policies,ciba,par,step-up-authentication,scripts,preview
ENV KC_DB=postgres
# Install providers
COPY ./deploy_custom_providers/*.jar providers/
RUN curl -sL https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar -o providers/keycloak-metrics-spi-2.5.3.jar
RUN /opt/keycloak/bin/kc.sh build

FROM quay.io/keycloak/keycloak:19.0.3
WORKDIR /opt/keycloak
COPY --from=builder /opt/keycloak .
# change these values to point to a running postgres instance
ENV KC_DB_URL=jdbc:postgresql://db/keycloak
ENV KC_DB_USERNAME=keycloak
ENV KC_DB_PASSWORD=REDACTED
ENV KC_HOSTNAME=REDACTED
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
CMD ["start", "--auto-build"]
```

---

<div class="post-metadata">

**Author:** ![TafkaMax](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tafkamax/32/6796_2.png) [@TafkaMax](https://forum.keycloak.org/u/TafkaMax)\
**Post date:** [October 20, 2022, 10:51am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/10 "2022-10-20T10:51:15Z")

</div>

It should pop up here, if I am correct.

 ![image](https://global.discourse-cdn.com/free1/uploads/keycloak/original/2X/a/a4f70552df5f59c4f9bc88ffecf49f7394fcaad7.png)

---

<div class="post-metadata">

**Author:** ![TafkaMax](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tafkamax/32/6796_2.png) [@TafkaMax](https://forum.keycloak.org/u/TafkaMax)\
**Post date:** [October 20, 2022, 11:06am UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/11 "2022-10-20T11:06:26Z")

</div>

My .jar file had an extra folder in it /build\_folder/META-INF

I generated the jar with ansible, so i needed to fix the ansible command it it created it the right way, and I can use the [quay.io](http://quay.io) image and don’t have to build it myself.

---

<div class="post-metadata">

**Author:** ![gustavoluigi](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/gustavoluigi/32/6991_2.png) [@gustavoluigi](https://forum.keycloak.org/u/gustavoluigi)\
**Post date:** [November 9, 2022, 9:37pm UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/12 "2022-11-09T21:37:00Z")

</div>

Did you manage to make the final dockerfile? I’m having trouble how to make the dockerfile with keycloak image and my own scripts.

---

<div class="post-metadata">

**Author:** ![TafkaMax](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tafkamax/32/6796_2.png) [@TafkaMax](https://forum.keycloak.org/u/TafkaMax)\
**Post date:** [January 11, 2023, 2:18pm UTC](https://forum.keycloak.org/t/trouble-getting-custom-authentication-script-deployed-docker-19-0-2/17513/13 "2023-01-11T14:18:58Z")

</div>

I used the [quay.io](http://quay.io) image in the end.
