keycloak-nodejs-admin-client
keycloak-nodejs-admin-client copied to clipboard
PolicyRepresentation should have specific extended interface for Role Policies
Is your feature request related to a problem? Please describe.
Attempting to create a role-based policy by putting the role requirements in the config
object defined in PolicyRepresentation
causes an unknown error response from keycloak.
Example code:
await this.kcAdminClient.clients.createPolicy({
id: 'e7232c1b-c8bb-4ead-bdac-53522d49dfc1',
type: 'role',
realm: this.realm
}, {
name: 'prpfoobar',
description: 'created by aphex',
type: 'role',
logic: Logic.POSITIVE,
decisionStrategy: DecisionStrategy.UNANIMOUS,
config:{
roles: [{id: "49d3724c-1e52-41cd-8479-78d2e46995a8", required: true}]
}
});
However, if you put this at a root level object, everything works fine:
await this.kcAdminClient.clients.createPolicy({
id: 'e7232c1b-c8bb-4ead-bdac-53522d49dfc1',
type: 'role',
realm: this.realm
}, {
name: 'prpfoobar',
description: 'created by aphex',
type: 'role',
logic: Logic.POSITIVE,
decisionStrategy: DecisionStrategy.UNANIMOUS,
//@ts-expect-error
roles: [{id: "49d3724c-1e52-41cd-8479-78d2e46995a8", required: true}]
});
Describe the solution you'd like Ideally there would be <T extends PolicyRepresentation> for Role, Group, User, JS policies
Describe alternatives you've considered
Loading up the object works fine, but we need to use @ts-expect-error
or create our own internal interface to deal with this
Additional context None
when you put it at the root level isn't it then ignored by the server?
nope.. that seems to work fine.
right I see there is also the type: RolePolicyRepresentation
that it should use here instead, guess it's hard to use types here there are 12 different policy implementations
I just had the same problem and I found #483, which should solve this issue.