[keycloak-user] keycloak-admin-client and realm initialization

Marek Posolda mposolda at redhat.com
Tue May 31 08:23:31 EDT 2016


There is separate endpoint for creating new group role mappings or user 
role mappings. For example see this code snippet in the test how to do 
it for users: 
https://github.com/keycloak/keycloak/blob/master/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/UserTest.java#L791-L798 


For groups it is similar endpoint.

Marek

On 31/05/16 13:33, Okie Oth wrote:
> Thank you for the response :)
> I had the same idea and so I grab the existing realm roles from the
> server before I create the new group. A realm role with the desired name
> exists and I try to add it with ID and name in setRealmRoles.
>
> I also try to add a group at first, grab the group list from server and
> update the group with new (but existing) realm roles. With wireshark I
> sniff the content that goes to the rest service and it contains my data.
>
> The response was HTTP-State 202 (no data).
>
> I test my code against final version 1.9.4 and 1.9.5. The keycloak
> server runs in standalone mode in a Ubuntu 14.04 VM and uses Postgresql
> as backend.
>
> Beside the groups I got a similar effect if I create a new user. I can
> create the user, but he has no assigned group.
>
> Cheers
>
> Am 31.05.2016 um 13:03 schrieb Stan Silvert:
>> I suspect your problem is that the roles don't exist yet.  You need to
>> create the role as a realm role before you assign it to a group.
>>
>> realmResource.roles().create(myRole);
>>
>> On 5/31/2016 6:30 AM, Okie Oth wrote:
>>> Hello,
>>> I'm a keycloak newbie and try to write a tool that initialize my
>>> keycloak installation. Some parts work fine but I can't do deeper
>>> initializations. For instance I can create a new user group but if I
>>> want to assign some realm roles for the new created group nothing
>>> happens.
>>>
>>> I checked the results with the normal Keycloak webfrontend.
>>>
>>> Here is my sample code:
>>> ...
>>> GroupRepresentation gr = new GroupRepresentation();
>>> gr.setName("myGroup");
>>> List<String> realmRoleList=new ArrayList();
>>> realmRoleList.add("test");
>>> gr.setRealmRoles(realmRoleList);
>>> realmResource.groups().add(gr);
>>> ...
>>> // now the group 'myGroup' exists but no roles are assigned.
>>>
>>> Any advice or help is welcome
>>>
>>> Kind regards
>>> Eiko
>>>
>>>
>>> _______________________________________________
>>> keycloak-user mailing list
>>> keycloak-user at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/keycloak-user
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user



More information about the keycloak-user mailing list