Technology.
- java11
- springboot 2.7.2
- docker quay.io/keycloak/keycloak:19.0.2
Prerequisite.
- realmService.create(); // 大元のRealmなので先頭に実行
- clientScopeService.create(); // clientに設定するのでclientsServiceより先に実行
- clientsService.create();
- realmRoleService.create();
- groupService.create(); // group に roleを設定するのでrealmRoleServiceより後に実行
// groupService.create()
public void create() {
for (GroupEnum groupEnum : GroupEnum.values()) {
GroupRepresentation groupRepresentation = new GroupRepresentation();
groupRepresentation.setName(groupEnum.getName());
List<String> roles = Lists.newArrayList();
roles.add(RoleEnum.READ.getName());
roles.add(RoleEnum.WRITE.getName());
groupRepresentation.setRealmRoles(roles);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
getGroupsResource().add(groupRepresentation);
}
}
After creating the realm role in No4.
When I try to add a realm role while creating a group in No5, I cannot.
Confirmed that the role has been added before attempting to add it to the group.
Confirming that realm roles can be added to groups in the keycloak GUI.