Skip to content
Directory & LifecycleMarkdown

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.

  • 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.

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.

For each user in your export:

  1. 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" }'
  2. Create each group, on /objects/v1/group?id={group}.

  3. Link each member, on /objects/v1/group/{group}/relationships/member with { "targetId": "{user id}" }.

The full walk-through, with checks, is in Bring users from another system.

WhatDefault or limit
Objects per callOne: there’s no bulk endpoint
Rate of callsNo 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 bodyAbout 2 MB
Users created againRefused 409, not overwritten
Links made againNot refused: the same user is linked twice. Link only what’s missing
Passwords carried as hashesbcrypt only ($2a$, $2b$, $2y$)
AnswerCodeWhat it meansWhat to do
400POLICY_VIOLATION, SCHEMA_VALIDATION_FAILEDA rule of the type failed; detail names each failureFix the record in your export and send it again
401UNAUTHORIZEDThe script’s session endedSign in again and go on from where it stopped
409ALREADY_EXISTSThe user or group is already loadedSkip it, or PATCH it to update
5xxThe realm couldn’t answerWait a few seconds and send the same call again; a create that did go through answers 409 on the retry

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.

SymptomCauseFix
A loaded user’s old password doesn’t workTheir hash wasn’t bcrypt, so it was hashed again as if it were a passwordSet a new password for them
A user appears twice in a groupThe link was made in two runsRemove the link and make it once; on later runs, link only what’s missing
Fewer users than in your exportSome were refusedSearch for each missing id, fix it and send it again
  • 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 them active on the day you switch.

Staying in step with another system is planned: reconciliation, connectors and SCIM provisioning.