tml
tml

Reputation: 11

keycloak 8.0.1 , example app-authz-photoz failing on "import a resource server configuration"

I am using keycloak 8.0.1, and trying one of the examples. While following the README for the steps in .\keycloakExample\keycloak-quickstarts-latest\app-authz-photoz

This step:

import a resource server configuration. Now select the file that is located at:

keycloak-quickstarts/app-authz-photoz/photoz-restful-api/target/classes/photoz-restful-api-authz-service.json

results in:

ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-16) Uncaught server error: java.lang.RuntimeException: Error while importing policy [Only Owner and Administrators Policy]. at org.keycloak.models.utils.RepresentationToModel.importPolicies(RepresentationToModel.java:2220) at org.keycloak.models.utils.RepresentationToModel.toModel(RepresentationToModel.java:2180)

at org.keycloak.authorization.admin.ResourceServerService.importSettings(ResourceServerService.java:136)

Additionally, the steps say:

Now click Upload and the resource server will be updated accordingly.

There is not an Upload button, and there is an additional error:

RuntimeException: Script upload is disabled at org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.updatePolicy(JSPolicyProviderFactory.java:125)

==

This makes me think something in the configuration is not enabling this "upload button", so it isn't rendered, and the "import" button performs an script that tries to do an "upload"

Versions I am using: "Ubuntu" VERSION is "18.04.1 LTS (Bionic Beaver)" openjdk version "1.8.0_242"

Upvotes: 1

Views: 2567

Answers (1)

mitko501
mitko501

Reputation: 31

The reason is JavascriptPolicies are no longer enabled by default in Keycloak for security reasons. You have two options on how to solve this. Either you can enable UPLOAD_SCRIPTS feature with (-Dkeycloak.profile.feature.upload_scripts=enabled), or you can use a new Javascript provider. The later is preferred and more secure.

edit: In the latest version of the quickstart repository, this issue should be fixed (upload script JS policies are replaced with deployed policies).

Upvotes: 3

Related Questions