Skip to main content

Provision users to other applications

Let LumoAuth create and remove accounts in the tools that your people use, with a preset for each.

RecipeDraftView source
This page is a draft. The code exists, and not all of it has been run for this page yet. The page says what was checked.
Works with
Plain HTTP
Standards
SCIM 2.0

What it shows​

  1. You connect a target application from a preset, here Slack. The preset applies the habits of that vendor to every request.
  2. You choose which changes LumoAuth pushes: new users, changes, deletions and groups.
  3. A new person in LumoAuth gets an account in the target. A group with that person is created there too.
  4. The person leaves, and you block the account in LumoAuth. The target gets the person with active set to false.

LumoAuth is the SCIM client here: it sends the changes. To let an identity provider send changes to LumoAuth, see Provision users from an identity provider.

Before you start​

  • Check that your plan includes SCIM outbound provisioning and the Admin API in the plans matrix.
  • A target application with a SCIM API, and a token for it from its administrator. The address must be public HTTPS.
  • An API key with the scopes that the variables below name.
  • curl and jq.

You can also connect the target in the portal, and test it there:

  1. Open Settings, Integrations, then the tab SCIM provisioning.
  2. On the card Outbound SCIM, click Set up.
  3. Choose the vendor under Target preset, and fill in the address and the token.
  4. Click Save configuration, then Test connection.
  5. Switch on Enable outbound SCIM provisioning and the changes to push, and save again.
VariableValue
LUMOAUTH_URLThe address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region.
LUMOAUTH_ORG_IDYour organization, for example acme-corp.
LUMOAUTH_API_KEYAn API key with the scopes admin:settings:write, admin:users:read, admin:users:write, admin:groups:read and admin:groups:write.
TARGET_TOKENThe token that the target application gives you for its SCIM API, for example a Slack token with the admin scope.
TARGET_PRESETOptional. The key of the preset. The default is slack. Others: okta, onelogin, jumpcloud, google_workspace, salesforce, github, atlassian.
TARGET_URLOptional. The SCIM address of the target. The default is the address of Slack, https://api.slack.com/scim/v2.
PERSON_EMAILOptional. The email address of the test person. The default is jordan.lee@northwind.example.com.

Code​

connect.sh saves the target through the Admin API. changes.sh makes three changes that LumoAuth pushes: a new person, a group, and a block.

Run each command from the recipes folder of the examples repository. Set the folder up once for your language.

b2b/scim-to-other-apps/http/connect.sh
#!/bin/sh
# Connect a target application for outbound SCIM, with curl and jq: a preset,
# the address and the token of the target, and the changes to push.
#
# sh b2b/scim-to-other-apps/http/connect.sh
set -eu

# The preset applies the habits of one vendor to every request. Slack needs
# no placeholder in its address. For another vendor, set the preset key and
# its address: see the table of presets in the docs.
TARGET_PRESET="${TARGET_PRESET:-slack}"
TARGET_URL="${TARGET_URL:-https://api.slack.com/scim/v2}"

# jq builds the body, so that a token with special characters stays intact.
body=$(jq -n --arg preset "$TARGET_PRESET" --arg url "$TARGET_URL" --arg token "$TARGET_TOKEN" '{
outbound: {
enabled: true,
preset: $preset,
endpoint_url: $url,
auth_type: "bearer",
bearer_token: $token,
push_user_creates: true,
push_user_updates: true,
push_user_deletes: true,
push_group_changes: true
}
}')

# LumoAuth stores the token encrypted and never returns it.
curl --silent --show-error --fail-with-body --request PATCH \
"$LUMOAUTH_URL/orgs/$LUMOAUTH_ORG_ID/api/v1/admin/settings/scim" \
--header "X-API-Key: $LUMOAUTH_API_KEY" \
--header "Content-Type: application/json" \
--data "$body" \
| jq -r '.data.outbound
| "target: \(.preset) at \(.endpoint_url), enabled \(.enabled)",
"push: creations \(.push_user_creates), updates \(.push_user_updates), deletions \(.push_user_deletes), groups \(.push_group_changes)"'
b2b/scim-to-other-apps/http/changes.sh
#!/bin/sh
# Make the changes that LumoAuth pushes to the target, with curl and jq: a new
# person, a group with that person, and a block when the person leaves.
#
# sh b2b/scim-to-other-apps/http/changes.sh
set -eu

ADMIN="$LUMOAUTH_URL/orgs/$LUMOAUTH_ORG_ID/api/v1/admin"
EMAIL="${PERSON_EMAIL:-jordan.lee@northwind.example.com}"

admin() {
method="$1"; path="$2"; shift 2
curl --silent --show-error --globoff --request "$method" "$ADMIN$path" \
--header "X-API-Key: $LUMOAUTH_API_KEY" --header "Content-Type: application/json" "$@"
}

# A new person: LumoAuth sends POST /Users to the target. A second run finds
# the person of the first run.
USER_ID=$(admin GET "/users?search=$EMAIL" | jq -r --arg email "$EMAIL" '.data[] | select(.email == $email) | .id')
if [ -z "$USER_ID" ]; then
USER_ID=$(admin POST /users --data "{\"email\": \"$EMAIL\", \"name\": \"Jordan Lee\", \"emailVerified\": true}" | jq -r .data.id)
else
# A blocked account is not on the target. Unblocking sends it again.
admin POST "/users/$USER_ID/unblock" > /dev/null
fi
echo "person: $EMAIL ($USER_ID)"

# A group with the person in it: LumoAuth sends the group and its members.
if [ "$(admin GET /groups/support --output /dev/null --write-out '%{http_code}')" = 404 ]; then
admin POST /groups --data '{"name": "Support", "slug": "support", "description": "The support team"}' > /dev/null
fi
admin PUT "/users/$USER_ID/groups" --data '{"groups": ["support"]}' > /dev/null
admin GET /groups/support/members | jq -r '"group: support, members: \([.data[].email] | join(", "))"'

# The person leaves. A block sends the person to the target with active false.
admin POST "/users/$USER_ID/block" | jq -r '"\(.data.email // "person"): blocked \(.data.blocked // .data.isBlocked)"'
sh b2b/scim-to-other-apps/http/connect.sh && sh b2b/scim-to-other-apps/http/changes.sh

Compiles. Not run against an organization. Both scripts ran against an organization and printed these lines. No push reached a target application: the target must be a public HTTPS service, and none was available for the test.

Check the result​

Output
target: slack at https://api.slack.com/scim/v2, enabled true
push: creations true, updates true, deletions true, groups true
person: jordan.lee@northwind.example.com (01a21fde-4980-79bf-abca-eadac6eb2af8)
group: support, members: jordan.lee@northwind.example.com
jordan.lee@northwind.example.com: blocked true
  • In the admin console of the target, Jordan Lee has an account, and it is deactivated. The group Support lists Jordan Lee.
  • The portal page Outbound SCIM provisioning shows the preset and the address that connect.sh saved.
  • A push that the target refuses is listed on the Audit logs page as scim_outbound.push_failed, with the status that the target answered.

LumoAuth sends each change in the background, usually within seconds. The request that made the change never waits for the target.

Limits​

  • LumoAuth pushes every group of the organization. You cannot choose single groups.
  • Some targets have no groups, for example GitHub Enterprise Cloud and Microsoft Entra ID. For them, group changes are not sent.
  • A blocked or deactivated person is never created on the target. The account is created when the person is active again.
  • Batch sync in the portal brings the whole target up to date at a fixed interval, also after a push that failed.
  • The Admin API has no call for Test connection or Sync now: both are buttons of the portal page.