Unable to create a JS custom policy in Keycloak 26.0.5

I need to create a custom JS policy where I can write some code, but only below options are available

I enabled the features but unable to enable “upload-scripts”

ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-3) Uncaught server error: java.lang.RuntimeException: Script upload is disabled
at org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.throwCanNotUpdatePolicy(JSPolicyProviderFactory.java:129)
at org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.onCreate(JSPolicyProviderFactory.java:59)
at org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.onCreate(JSPolicyProviderFactory.java:20)
at org.keycloak.models.utils.RepresentationToModel.toModel(RepresentationToModel.java:1295)
at org.keycloak.authorization.AuthorizationProvider$3.create(AuthorizationProvider.java:349)
at org.keycloak.authorization.admin.PolicyService.create(PolicyService.java:149)
at org.keycloak.authorization.admin.PolicyService.create(PolicyService.java:120)

Any help here ?

Check Server Developer Guide
you need to enable the script feature and provide the js script via a jar file ( direct upload of js got dropped in 18.0 due to too many security concerns)

I created a custom jar and placed it under /providers but still I dont see my provider under Policies. Also, my provider name is not anywhere in logs so I think its not getting loaded. Can you help how to load it ?

DId you run the ./bin/kc.sh build or .bin/kc.bat build (for windows) to build it?.

Kc.sh show-config should show you if it’s there