keycloak-nodejs-admin-client icon indicating copy to clipboard operation
keycloak-nodejs-admin-client copied to clipboard

Cannot update a group policy using the updatePolicy method in clients.

Open mastery-amit-sahani opened this issue 3 years ago • 1 comments

Describe the bug

Hello

I'm trying to make use of the kcAdminClient.clients.updatePolicy() method to update a role based policy. Below is the necessary query and payload data that I'm sending along with the PUT request.

await kcAdminClient.clients.updatePolicy({
    id: "<resource-server uuid>",
    type: "role",
    realm: "abc",
    policyId: "<policy uuid>",
}, {
    id: "<policy uuid>",
    decisionStrategy: DecisionStrategy.UNANIMOUS,
    logic: Logic.POSITIVE,
    description: "",
    type: "role",
    name: "abc policy",
    config: {
        roles: [{
                id: "<role uuid 1>"
            }, {
                id: "<role uuid 2>"
            },
        ],
    },
});

Since there is no roles field in PolicyRepresentation, I believe sending roles under config is the right way. I also tried sending other parameters like resources, scopes, owner mentioned in the PolicyRepresentation interface.

Also to verify the user account, I'm calling the keycloak API directly through insomnia and that works. I don't know what I'm missing here.

Version

17.0.0-dev.20

Expected behavior

I should be able to update a role based policy.

Actual behavior

The updatePolicy() method mentioned above returns 500.

How to Reproduce?

No response

Anything else?

No response

mastery-amit-sahani avatar Feb 03 '22 11:02 mastery-amit-sahani

this fix it for me on 16, possible 17,18,19-dev it works too

https://github.com/keycloak/keycloak-nodejs-admin-client/pull/483

ClemensSahs avatar May 12 '22 21:05 ClemensSahs