Bring users in
Load the users and groups you already have from another system into the realm, with their passwords, so they sign in the next day as they did before.
Available, with limitsAPI
When you move to the realm from another system, your users shouldn’t notice. Export them, load them through the API, and they keep their sign-in names, their profiles, their groups and, where the old system kept bcrypt hashes, their passwords. Nobody has to reset anything.
What the realm doesn’t do yet is stay in step with that system afterwards. Loading is one-way and runs when you run it; see Coming next.
Before you begin
Section titled “Before you begin”- Privilege:
RealmOwner, or a privilege of your own over users and groups. See Who may do what. - Where: the API, from a script, with a realm administrator’s session in
$CVYUH_SESSION(see Call the API). A script signs in as an account of its own. - Your own attributes first, added to your user type before the load.
How it works
Section titled “How it works”You write each user to the realm as you would by hand, from a script that reads your export. Everything that applies
to a user written by hand applies here: the type’s rules are checked, uid must be unique, and a user that fails is
refused with every reason, while the rest go on loading.
Passwords carry over as hashes. The realm stores passwords as bcrypt hashes. A value written to passwordHash
that is already a bcrypt hash (it starts $2a$, $2b$ or $2y$) is stored exactly as given, so the user’s existing
password keeps working. Anything else is taken as a password and hashed. Passwords the old system kept in another
scheme can’t be carried over. Those users can’t set a password on their own yet, since there’s no self-service
password reset: a realm administrator sets a first password for each, and the user signs in with it. See
Known limitations.
Groups and links come after. Create the users and the groups first, then link each user to their groups. A link names objects that must already exist.
Your own attributes come with them. Add an attribute such as employeeId to your realm’s user type before you
load (see Attributes and validation), and you can load it with
everything else, and later find users by it.
Set it up
Section titled “Set it up”For each user in your export:
-
Create the user, with their old hash:
Terminal window curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/user?id=ben" \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "uid": "ben", "firstName": "Ben", "lastName": "Okafor", "email": "ben@example.com","passwordHash": "$2b$12$Ez6…", "employeeId": "E004118" }' -
Create each group, on
/objects/v1/group?id={group}. -
Link each member, on
/objects/v1/group/{group}/relationships/memberwith{ "targetId": "{user id}" }.
The full walk-through, with checks, is in Bring users from another system.
Limits and defaults
Section titled “Limits and defaults”| What | Default or limit |
|---|---|
| Objects per call | One: there’s no bulk endpoint |
| Rate of calls | No rate limit today. Send calls one at a time, or a few at once, and wait for each answer, so the load doesn’t slow your users’ sign-ins |
| A request body | About 2 MB |
| Users created again | Refused 409, not overwritten |
| Links made again | Not refused: the same user is linked twice. Link only what’s missing |
| Passwords carried as hashes | bcrypt only ($2a$, $2b$, $2y$) |
When a call fails
Section titled “When a call fails”| Answer | Code | What it means | What to do |
|---|---|---|---|
400 | POLICY_VIOLATION, SCHEMA_VALIDATION_FAILED | A rule of the type failed; detail names each failure | Fix the record in your export and send it again |
401 | UNAUTHORIZED | The script’s session ended | Sign in again and go on from where it stopped |
409 | ALREADY_EXISTS | The user or group is already loaded | Skip it, or PATCH it to update |
5xx | The realm couldn’t answer | Wait a few seconds and send the same call again; a create that did go through answers 409 on the retry |
Audit record
Section titled “Audit record”Every user, group and link the load writes is recorded like a write by hand: CREATED for each user and group,
UPDATED on the group for each link, with the script’s account as the one who made it. To see what a load did, read
the trail for that account. See What is recorded.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| A loaded user’s old password doesn’t work | Their hash wasn’t bcrypt, so it was hashed again as if it were a password | Set a new password for them |
| A user appears twice in a group | The link was made in two runs | Remove the link and make it once; on later runs, link only what’s missing |
| Fewer users than in your export | Some were refused | Search for each missing id, fix it and send it again |
Good to know
Section titled “Good to know”- A load of users can be run again safely. A user whose id is already taken is refused, not overwritten, so you can run the same load again after fixing the users that failed. Links are different: check a group’s members before linking again.
- Users can be loaded inactive. Send
"status": "inactive"to load accounts that shouldn’t sign in yet, and set themactiveon the day you switch.
Coming next
Section titled “Coming next”Staying in step with another system is planned: reconciliation, connectors and SCIM provisioning.
Related
Section titled “Related”- Bring users from another system: the task, start to finish.
- Add and change users: every attribute a user has.
- Add groups and members: links between users and groups.