Skip to content
Directory & LifecycleMarkdown

Joiners, movers and leavers

What to change in the directory when someone starts, changes role or leaves, and what the realm does for you at each step.

AvailableAPI

When someone joins, create them and put them in their groups. When they move, change their attributes and their groups. When they leave, set them inactive. Each is one or two calls, and the realm turns them into who may sign in, what their tokens carry and what they can reach, everywhere at once.

There are no approval steps or scheduled tasks yet (see Coming next), so a change takes effect when you, or a script of yours, writes it.

  • Privilege: RealmOwner, or a privilege of your own over users and groups; ending sessions needs MODIFY on the realm’s sessions, which RealmOwner has. See Who may do what.
  • Where: the API, with your session in $CVYUH_SESSION (see Call the API).
  • Attributes you move on, such as department, added to your user type first.

Create the user with their profile and put them in their groups. Groups carry everything else: the entitlements a group holds, the policies that name it, the secrets in its vault and, for administrators, the realms they may administer. A joiner is ready as soon as their links are made.

For someone who should have access only for a while, such as a contractor or an intern, set accountExpiry when you create them. They can sign in until that moment and not after, with nothing left for you to remember.

To prepare accounts ahead of a start date, create them with "status": "inactive" and set them active on the day.

When someone changes team, change their attributes (department, a title, a manager, each an attribute you add) and move their links: remove them from the groups they’re leaving and add them to the ones they’re joining. What the old groups gave them stops on their next request; what the new ones give starts on it.

Access someone needs for a set time, such as cover for a colleague, is an entitlement granted with validFrom and validTo. It starts and ends by itself, and nothing has to be removed afterwards. See Entitlements.

With membership worked out from rules, a change of department is the whole move: the user leaves the sets whose rules they no longer match and joins the ones they now do, in the same write. See Rule-based membership.

Set the user’s status to inactive. From that moment they can’t sign in, no app can get a new token for them, their refresh tokens stop working, and their tokens read as inactive to any app that asks the realm. Then end the sessions they already hold, hand their agents to a new owner, and take back what others shared with them.

An access token issued before you set them inactive stays valid, at an app that checks it itself, until it expires: five minutes by default. Apps that introspect see it as inactive at once. See Turn access off and on.

Keep the inactive record for as long as you need it, for an audit or in case they return. Deleting them later removes the user and every link to them, and their personal vault with it, and leaves the agents they owned without an owner: hand those over first.

A leaver can also be stopped from outside: your identity provider can tell the realm a user was disabled, and their access here ends at once. See Receive signals.

Every call is on https://foobar.cvyuh.com/api/v0/am:

MomentChangeCall
JoinCreate the userPOST /objects/v1/user?id={id}
JoinAdd to a groupPOST /objects/v1/group/{group}/relationships/member with { "targetId": "{id}" }
JoinAccess until a datePATCH /objects/v1/user/{id} with { "accountExpiry": "<RFC 3339 time>" }
MoveChange attributesPATCH /objects/v1/user/{id} with the fields that changed
MoveLeave a groupDELETE /objects/v1/group/{group}/relationships/member/{id}
LeaveStop sign-in and tokensPATCH /objects/v1/user/{id} with { "status": "inactive" }
LeaveEnd their sessionsPOST /sessions/v1/end with a filter on user
LeaveHand over their agentsDELETE then POST on /objects/v1/agent/{agent}/relationships/businessOwner
LeaveLeave every groupPATCH /objects/v1/user/{id} with { "memberOf": [] }
LeaveDelete the accountDELETE /objects/v1/user/{id} with If-Match

A mover, Ben, from engineering to finance:

Terminal window
curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/user/ben \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "Content-Type: application/json" \
-d '{ "department": "Finance" }'
curl -X DELETE https://foobar.cvyuh.com/api/v0/am/objects/v1/group/engineering/relationships/member/ben \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "If-Match: *"
curl https://foobar.cvyuh.com/api/v0/am/objects/v1/group/finance/relationships/member \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "Content-Type: application/json" \
-H "If-Match: *" \
-d '{ "targetId": "ben" }'

department is an attribute you add to your user type first: see Attributes and validation. The leaver’s steps, in order and with what to check, are in Offboard a leaver.

WhatDefault or limit
When a change takes effectAt once, for sign-in and new tokens; on their next request, for what a group gives
An access token issued before a leaver is set inactiveValid until it expires at apps that check it themselves: five minutes by default
Sessions ended by one end callUp to 10,000; call again if ended comes back at that number
Scheduled or approved stepsNone yet: each step runs when you make it

Each step is on the trail: the user’s CREATED, PATCHED and DELETED; each group’s UPDATED as members come and go; a LOGOUT for every session you end, naming you as the one who ended it; and each refused sign-in afterwards as LOGIN_FAILED. Read them in the user’s change history and on the audit trail.

SymptomCauseFix
A leaver still reaches an appA session or an access token issued before they were set inactiveEnd their sessions; the access token ends within its lifetime
A mover kept their old group’s accessThe old membership link is still thereRemove it; check the user with ?expand=memberOf/*
A deleted leaver’s agents have no ownerDeleting removed the owner linksName a new owner for each: Agent records
  • Inactive is reversible; delete isn’t. Set a returning user active and everything they had is still there. A deleted user is gone, with their links and their personal secrets.
  • Changing status doesn’t end sessions. Sign-in and token issue stop at once, but a session already open stays until it ends or you end it.
  • Expiry is checked at the moment of use. Nothing runs at the expiry time; each sign-in and each token request compares it with the clock.
  • A leaver’s agents need a decision. An agent acting for an inactive user gets no new token for them. An agent they own has an identity of its own, which goes on until you stop it or name a new owner. Hand it over before you delete the user: deleting removes the owner link and leaves the agent with none. See Agent records.

Workflows, lifecycle hooks, access reviews, invitations and personal data export are planned. See What’s next for lifecycle.