capabilities.work

Assign a User to a Group

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

Recipe · 4 steps

Assign a User to a Group

with Keycloak · Identity & Access Management

Add a user to a group by username and group name, then verify the membership.

  1. Resolve the account UUID from the username. The membership endpoint accepts only UUIDs, so this lookup is mandatory rather than convenience.
  2. Resolve the group UUID by searching top-level groups by name. Note this searches root groups; a nested subgroup has to be addressed by the id from its parent's subGroups tree instead.
  3. Add the user to the group. This is a PUT, so applying it to a user who is already a member succeeds quietly rather than conflicting.
  4. Read the user's group list back to prove the membership landed, and to show the caller every other group the account now inherits access from.
What you'll need to have ready
  • realm: The name of the realm the user and group live in.
  • username: The username of the account to add to the group.
  • groupName: The name of the top-level group to add the user to.
For your developer

Arazzo workflow keycloak:assign-user-to-group, 4 operations: getUsers → getGroups → addUserToGroup → getUserGroups. Specs on APIs.io.