Add users and groups
Create your first users, put them in their groups, and see one of them sign in, in about ten minutes.
API
Your engineering and finance teams are starting to use the realm. You add Maya and Ben, create an engineering and a
finance group, put each of them in theirs, and check that Maya can sign in. Everything you give a group from then
on reaches its members.
Before you start: you’re a realm administrator holding RealmOwner, with your session in $CVYUH_SESSION (see
Call the API).
Add them
Section titled “Add them”-
Create Maya, naming her
maya, with a first password:Terminal window curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/user?id=maya" \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "uid": "maya", "firstName": "Maya", "lastName": "Chen", "displayName": "Maya Chen","email": "maya@example.com", "passwordHash": "<a first password>" }'The realm answers
201with her record. Her password isn’t in it: the realm stored only a hash of it. -
Create Ben the same way, with
?id=benand his own details. -
Create the groups:
Terminal window curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/group?id=engineering" \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "displayName": "Engineering", "description": "Everyone who builds the product" }'curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/group?id=finance" \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "displayName": "Finance", "description": "Everyone who runs the books" }' -
Put each of them in their group:
Terminal window curl https://foobar.cvyuh.com/api/v0/am/objects/v1/group/engineering/relationships/member \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-H "If-Match: *" \-d '{ "targetId": "maya" }'Then the same on
/objects/v1/group/finance/relationships/memberwith{ "targetId": "ben" }. Each answers201.
Check it worked
Section titled “Check it worked”Read Maya with her groups:
curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/user/maya?expand=memberOf/*" \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"engineering is in her memberOf, and her status is active, filled in by the realm. Then have Maya sign in to
the realm with maya and her password. She’s in.
Undo it
Section titled “Undo it”Remove a member with DELETE on /objects/v1/group/engineering/relationships/member/maya. Delete a user or a group
with DELETE on /objects/v1/user/{id} or /objects/v1/group/{id}, each with If-Match: * or the revision you
read.
Related
Section titled “Related”- Add and change users: every attribute a user has.
- Add groups and members: what membership gives, and where groups are used.
- Add your own attribute to users: keep an employee number or a department.
- Entitlements: give the group what its members may do.