mayope / keycloakmigration

Manage your Keycloak configuration with code.
https://mayope.net
MIT License
111 stars 23 forks source link

Adding a role to the realm default roles #63

Closed aberg09 closed 1 year ago

aberg09 commented 1 year ago

Hi again,

I wonder if there is a way to add roles to the default roles for a realm (specifically a client role, if that should matter). I have had a look at the REST Api and tried to replicate that with keycloakmigration using the updateRole. However, I could not get it running. Is this supported already?

Best regards

klg71 commented 1 year ago

Hey @aberg09 thanks for opening an issue for this topic. I tried it out through the GUI in 18.0.2. In 18.0.2 default roles of a realm are simply another composite role where you can add your own roles to. Did you try the updateRole-Action on the default-roles-{realm} realmRole? There is an option compositeChildRoles that expects a list of type RoleSelector. RoleSelector does have the attributes name(mandatory) and clientId(optional) My own documentation is lacking in that case but I could work in my eyes :)

aberg09 commented 1 year ago

Yes, it works as you proposed. I do not know why I could not get that running before ... Anyway. Thank you very much for the help!