SCIM Group Response Converter Lambda

On this page

A SCIMAn open standard defining an HTTP REST protocol and schema for automating user and group provisioning across systems. Group Response Converter lambda converts a FusionAuth group into the SCIM Group response that FusionAuth returns to the SCIM client. FusionAuth runs the lambda after FusionAuth acts on the group.

When you create a lambda in the Admin UI, FusionAuth provides an empty function for you to implement.

Lambda Structure#

If you create the lambda with the API, the function must have the following signature:

function convert(scimGroup, group, members, context) {
  // Lambda code goes here
}

The lambda must contain a function named convert that accepts the following parameters:

  • scimGroup: the SCIM response. You can modify this object.
  • group: the FusionAuth group. This object is read-only.
  • members: the memberships of the group. This array is read-only. Each membership has the userId of the member, the membership data, the groupId, the membership id, and the insertInstant.
  • context: Available since 1.64.0 the context of the request, including access to secrets. This object is read-only.

The Group API documents the FusionAuth group and the memberships. The scimGroup object holds the SCIM Group response JSON. See SCIM Group.

Before the lambda runs, FusionAuth fills in the following scimGroup fields:

  • id: the FusionAuth group Id.
  • externalId
  • schemas: the Group schema.
  • meta: created, lastModified, resourceType, and location, the URI of the group resource.
  • members: one entry for each member, with value, display, and $ref. FusionAuth leaves out members whose user no longer exists.

FusionAuth doesn't set displayName, so the lambda must set displayName.

Assign the Lambda#

After you create the lambda, assign the lambda to a tenant on the SCIM tab of the tenant configuration.

Default Lambda#

FusionAuth provides a default SCIM Group Response Converter lambda. The default lambda sets the SCIM displayName to the FusionAuth group name.

The default SCIM Group Response Converter lambda.
function convert(scimGroup, group, members) {
  // Un-comment this line to see the group object printed to the event log
  // console.info(JSON.stringify(group, null, 2));

  // Set the outgoing displayName on the SCIM group using the FusionAuth group name.
  scimGroup.displayName = group.name;
}

Example: Return the Original Display Name#

The role mapping example for the SCIM Group Request Converter adds a prefix to the group name. The following lambda returns the original name from group.data.scimDisplayName instead. For a group created in FusionAuth, the lambda falls back to the group name.

A lambda that returns the SCIM display name without the group name prefix.
// returns the group name the SCIM client sent, without the prefix the request converter added
function convert(scimGroup, group, members, context) {
  scimGroup.displayName = (group.data && group.data.scimDisplayName) || group.name;
}