capabilities.work

Provision a Group Hierarchy

A 4-step recipe with Keycloak. We can help you get access.

Recipe · 4 steps

Provision a Group Hierarchy

with Keycloak · Identity & Access Management

Create a parent group with a nested child group and return the resulting tree.

  1. Create the top-level group. Keycloak answers 201 with no body and no Location header, which is why the next step has to go looking for the id.
  2. Recover the parent group's UUID by searching the realm's top-level groups by name. This is the only route to the id, and the child endpoint cannot be called without it.
  3. Nest the subgroup beneath the resolved parent using the dedicated children endpoint. Posting to the top-level groups endpoint instead would silently create a second root group rather than a child.
  4. Read the parent group back to confirm the child was nested correctly and to return the full subGroups tree with the generated paths.
What you'll need to have ready
  • realm: The name of the realm to provision the groups in.
  • parentGroupName: The name of the top-level group (e.g. "engineering").
  • childGroupName: The name of the subgroup to nest beneath the parent (e.g. "platform").
  • parentAttributes: Optional attributes for the parent group, as a map of name to an array of string values.
  • parentRealmRoles: Realm-level roles to attach to the parent group.
  • childRealmRoles: Realm-level roles to attach to the child group.
For your developer

Arazzo workflow keycloak:provision-group-hierarchy, 4 operations: createGroup → getGroups → createChildGroup → getGroup. Specs on APIs.io.