1 min read

Keycloak - script upload is disabled

Keycloak script upload is disabled
Keycloak - script upload is disabled
Photo by Sarah Kilian / Unsplash

Say you export your keycloak realm, and then try to import this realm and use it in integration test, only for you to get hit with a weird error.

ERROR: Script upload is disabled
Error importing previously exported realm
Integration test setup to import realm

Why the error?

The recommended way to add javascript policy for authorization is to deploy a jar. Previous versions of keykloak allowed to write a js script in the Admin console and run it at runtime. This was disabled as a security enhancement. However, the js policies are still available when we export a newly created realm. This is baggage that needs to cleaned up. (I'm sure will be in future versions of keycloak).

Solution

For our use-case; we do not need to add a js policy for authorization. So we simply remove the authorizationSettings property from the realm export. If you have another use-case or need a js policy, I point you to the server documentation on how to prepare and deploy a jar.

authorizationSettings property is present. Should be removed

Happy Coding!!!