Deploy a Javascript Policy in Keycloak 10

I’ve followed the Create a JAR with the scripts to deploy instruction to create a custom Javascript policy for checking user attributes and it seems to be deployed successfully, however, I can’t see the policy name in the create policy dropdown . Is there any setting I need to enable for this feature?

After uploading the .jar file to /keycloak/standalone/deployments , it says WFLYSRV0010: Deployed "script.jar" (runtime-name : "script.jar") without any error. I can also see the {filename}.jar.deployed next to my script file.

Setup: I use docker-compose to launch a jboss/keycloak version 10.0.1 container. Here’s my docker-compose file:

version: "3.1"
services:
    keycloak:
        image: jboss/keycloak
        restart: always
        ports:
            - 8080:8080
        environment:
            KEYCLOAK_PASSWORD: admin
            KEYCLOAK_USER: admin
        volumes:
            - ./deployments:/opt/jboss/keycloak/standalone/deployments

script.jar/META-INF/keycloak-scripts.json:

{
    "policies": [
        {
            "name": "my-policy",
            "fileName": "my-script-policy.js",
            "description": "My Policy from a JS file"
        }
    ]
}

script.jar/my-script-policy.js:

var context = $evaluation.getContext();
var contextAttributes = context.getAttributes();

if (contextAttributes.containsValue('kc.client.network.ip_address', '127.0.0.1')) {
    $evaluation.grant();
}

Client policy setting

Thank you in advance for any suggestions.

@behrooz-tahanzadeh I am encountering the same issue as you described. Did you get this solve eventually ?

Unfortunately not, but we end up using the built in ones and they’re sufficient for us.
TBH I’m glad we didn’t use this feature :smiley: