I am using the following docker image
docker run -e KEYCLOAK_USER=demo
-e KEYCLOAK_PASSWORD=demo
-e KEYCLOAK_IMPORT=/tmp/quarkus-realm.json -v /tmp/quarkus-realm.json:/tmp/quarkus-realm.json
-p 8180:8080 quay.io/keycloak/keycloak
The realm doesnt show up in the realms on the UI.
I also tried to import it from the UI and gives the following exception:
00:51:37,894 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-7) Uncaught server error: java.lang.RuntimeException: Script upload is disabled
at org.keycloak.keycloak-authz-policy-common@7.0.1//org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.updatePolicy(JSPolicyProviderFactory.java:125)
at org.keycloak.keycloak-authz-policy-common@7.0.1//org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.onImport(JSPolicyProviderFactory.java:70)
at org.keycloak.keycloak-server-spi-private@7.0.1//org.keycloak.models.utils.RepresentationToModel.toModel(RepresentationToModel.java:2232)
As we discussed on IM, this is down to the fact that from 7.0.1 onwards we donât allow uploading JS scripts to Keycloak through admin endpoints/console and require these to be deployed in a similar fashion to Java providers. Take a look at the docs on how to package your JS scripts as a deployment instead of defined within the realm json file.
I am somewhat lost as I have been trying to setup a repeatable install of keycloak for days now, so that we can run independent integration tests, but just canât get keycloak to work. All âsolutionsâ I see require setting up realms or users via the UI which forbids itself for automated testing.
Please can you share some more info on how to import a realm in keycloak from version 7.0.1? I have the same problem of @sshaaf and I would prefer to keep using version 8.0.1 of keycloak.
Same problem here with keycloak 8.0.1 docker image, impossible to import realm file using documented arg -e KEYCLOAK_IMPORT=PATH_TO_MY_JSON_FILE
Uncaught server error: java.lang.RuntimeException: Script upload is disabled
As a workaround I have to exec this command in the keycloak running container to import my json file: /opt/jboss/keycloak/bin/standalone.sh -Djboss.socket.binding.port-offset=100 -Dkeycloak.migration.action=import -Dkeycloak.profile.feature.upload_scripts=enabled -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=PATH_TO_MY_JSON_FILE
Same error, but also somehow it worked once and then stopped. Really hard to make a repeatable environment with such errors. I didnât add any JS-based validations for the realm or my clients, so I donât know where the error is coming from.
I had the same problem, in Openshift, I made it work by adding the command â-Dkeycloak.profile.feature.upload_scripts=enabledâ to the end of the KEYCLOAK_IMPORT parameter ::
Using Keycloak 8.0.1 or 9.0.0, I can import a simple realm.json file created with just some users added.
However, another realm.json file which is the first one with some additions: Policies / Scopes / Resources following the tutorial at https://github.com/v-ladynev/keycloak-nodejs-example doesnât work.
Message is:
Unable to import realm my_realm from file /tmp/my_realm.json.: java.lang.RuntimeException: Script upload is disabled
at org.keycloak.keycloak-authz-policy-common@9.0.0//org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.updatePolicy(JSPolicyProviderFactory.java:125)
No solution seems to work. The one proposed by NiCo using /opt/jboss/keycloak/bin/standalone.sh doesnât return any error but nothing shows up in the admin panel.
[org.keycloak.exportimport.util.ImportUtils] (ServerService Thread Pool â 68) Realm âmy_realmâ imported
10:04:42,340 INFO [org.keycloak.services] (ServerService Thread Pool â 68) KC-SERVICES0032: Import finished successfully
My command line:
docker run -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e KEYCLOAK_IMPORT=/tmp/my_realm.json -v %CD%/my_realm2020-02-14.json:/tmp/my_realm.json --name kc -p 8041:8080 jboss/keycloak:9.0.0
I faced this issue when I try to migrate from 7.0.0 to 8.0.1 via realm.json. I believe this is a workaround and need to try out the directory approach from now onward.
Yes, adding -Dkeycloak.profile.feature.upload_scripts=enabled to the java environment solves the problem for me.
with docker: e.g. create your own Dockerfile with FROM jboss/keycloak and ENTRYPOINT [ "/opt/jboss/tools/docker-entrypoint.sh, â-Dkeycloak.profile.feature.upload_scripts=enabledâ ] or whatever you use to add a parameter to the startup script, like COMMAND âŚ
The solution is add -Dkeycloak.profile.feature.upload_scripts=enabled
-e KEYCLOAK_IMPORT="/tmp/realm-export.json -Dkeycloak.profile.feature.upload_scripts=enabled" \
EXAMPLE
docker run --rm
-p 8080:8080
-v ~/download/realm-export.json:/tmp/realm-export.json
-e KEYCLOAK_USER=admin
-e KEYCLOAK_PASSWORD=admin
-e KEYCLOAK_IMPORT="/tmp/realm-export.json -Dkeycloak.profile.feature.upload_scripts=enabled"
jboss/keycloak