0

Technology.

  • java11
  • springboot 2.7.2
  • docker quay.io/keycloak/keycloak:19.0.2

Prerequisite.

  1. realmService.create(); // 大元のRealmなので先頭に実行
  2. clientScopeService.create(); // clientに設定するのでclientsServiceより先に実行
  3. clientsService.create();
  4. realmRoleService.create();
  5. 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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.