Skip to main content
Version: Dev

SCIM Directory Sync

SCIM directory sync connects an AISIX organization to your identity provider (IdP), so member accounts can be created, updated, and deactivated from the directory. AISIX implements the SCIM 2.0 protocol (RFC 7643/7644), which Okta, Microsoft Entra ID, and other enterprise IdPs support natively.

Directory sync is built for organizations that attribute gateway usage to many people, including hundreds or thousands of members, without dashboard logins for each of them.

What a provisioned user becomes depends on whether AISIX trusts the organization's identity provider for the user's email address, the same decision that single sign-on makes. AISIX Enterprise trusts it for every address. AISIX Cloud trusts it only for addresses on the organization's verified domains.

  • A trusted address becomes a member at once. When the email is new to AISIX, directory sync creates a login-less member, like one an AISIX Enterprise administrator can create directly: it owns API keys, carries rate limits and budgets, and appears in usage reporting, but cannot sign in to the dashboard until an administrator enables sign-in for it, or the person connects it through SSO. When the email already belongs to an AISIX account that is not yet a member of this organization, directory sync attaches the new membership to that account instead, so the person can sign in with the account's existing credentials. In AISIX Cloud, an account that was registered for the address but never verified it is taken over: it loses its password, its sessions, its pending email verification links, and its SSO links. It takes the name a new account would get from the request, displayName or name, falling back to the email address, its acceptance of the User Agreement and Privacy Policy is cleared, and its email address is marked verified. The takeover is recorded as a verified_domain_claim audit entry; see Audit Records.
  • Any other address becomes a member waiting to join. No account is created or attached. AISIX invites the address, and the person joins by accepting the invitation or by connecting the organization's SSO. See Members Waiting to Join.

When a person is deactivated or removed in the IdP, AISIX deactivates the member and disables every API key that member owns. The change propagates to the gateway data plane, so the credentials stop working at the gateway itself, not only in the dashboard.

Enable Directory Sync​

  1. Open Settings, select the Authentication tab, and find the Directory sync (SCIM) card.

  2. Turn on Enable SCIM provisioning (organization admins and owners only).

  3. Copy the SCIM base URL shown on the card, for example:

    https://<your-cp-api-host>/scim/v2
  4. Select Generate SCIM token (organization owners only) and copy the plaintext value before leaving the page. It is shown exactly once.

Export the values when you want to test the SCIM endpoints from the shell:

export AISIX_SCIM_BASE_URL="https://<your-cp-api-host>/scim/v2"
export AISIX_SCIM_TOKEN="YOUR_SCIM_TOKEN"

Configure the SCIM connector in your IdP with the same base URL and token as the bearer credential. The token is an admin token with the exclusive scim scope. It can call only the SCIM endpoints and is rejected on every other AISIX Cloud Admin API route, so a leaked IdP credential cannot read or change gateway resources.

To rotate the credential, generate a new SCIM token, update the IdP connector, and revoke the old token on the Admin tokens page.

Manage the SCIM Token​

Starting with 1.11.0, a SCIM token is an organization-level credential rather than an extension of the owner who generated it:

  • It outlives its issuer's role. The token keeps working after the owner who generated it is demoted or leaves the organization, until an owner revokes it. What it can do is still limited by the scim scope.
  • Other owners can manage it. Every SCIM token appears in the Admin tokens list, where any owner can revoke it, including one whose issuer has left.
  • It stops with the organization. While the organization is being deleted, the SCIM endpoints answer 404 with a SCIM error body.

Replace a Token Whose Issuer Is No Longer an Owner​

When the owner who generated a SCIM token is no longer an owner, the token still works, but someone outside the owner group may still hold its plaintext value. AISIX points such tokens out:

  • The Admin tokens list marks each active SCIM token whose issuer is no longer an owner with Issuer is no longer an owner or Issuer left the organization. An issuer whom the identity provider deactivated counts as no longer an owner.
  • The Directory sync (SCIM) card shows a Replace these SCIM tokens notice that lists the same tokens.
  • When an owner is demoted or removed in the dashboard, or deleted or deactivated through SCIM, the audit log records one flag entry on each active SCIM token that owner issued. See SCIM Calls in the Audit Log.

Rotate the SCIM token whenever the owner who issued it leaves the organization or stops being an owner. Have a current owner generate a new SCIM token, replace the old one in the IdP connector, confirm that provisioning still succeeds, and then revoke the old token on the Admin tokens page.

Audit Attribution​

Changes made through /scim/v2 are recorded in the audit log with the SCIM token as the actor, shown as SCIM token followed by the token's name. Teams and members that directory sync creates still record the token's issuer as their creator.

How Users Map to Members​

SCIM attributeAISIX member field
userName / emails[].valueEmail address (the identity key)
displayName or nameDisplay name of an account that directory sync creates
externalIdStable IdP identifier, unique per organization
activefalse deactivates the member and disables its API keys
groupsTeam membership (read-only; managed through the Groups endpoints)

SCIM responses return the userName, name, displayName, and emails that the IdP sent, along with the AISIX id, externalId, active, and groups. They never return the name or email address of the AISIX account, so they do not reveal whether an address already has an account. A member that directory sync did not create, or created before the control plane stored the IdP's values, returns the account's stored email address and name instead.

SCIM changes the name and email address of the account behind a member only when the account has no password and belongs to no other organization. In AISIX Cloud, it also requires the new email address to be on one of the verified domains. Otherwise, the account keeps its name and address, AISIX stores the IdP's new values, and responses return them.

Creating a user whose email already belongs to a member of the organization returns a 409 uniqueness error. Members created in the dashboard stay dashboard-managed. They are visible to the IdP in list responses, but SCIM cannot modify, deactivate, or delete them. Directory sync can never modify an organization owner.

Deleting a user over SCIM disables the member's API keys first, removes the member from every team, and then removes the membership. As with removing a member in the dashboard, the member's budget and classic rate limit policies are deleted too. Usage history is preserved for reporting. The email becomes available again, so a later re-provision creates a fresh member.

Deactivate vs. Delete​

  • active: false keeps the member and its keys, but the keys are disabled at the gateway. Setting active: true again re-enables only the keys that directory sync disabled. Keys an operator disabled by hand stay disabled.
  • DELETE removes the membership permanently. Keys stay disabled and keep their usage history.

What a Deactivated Member Loses​

A deactivated member keeps its membership record and roles, but loses access to the organization, including through a dashboard session or a personal access token:

  • The organization no longer appears in GET /api/orgs, and the organization's routes return 403 with the error code NOT_A_MEMBER.
  • An API key cannot be bound to the member. Creating a key with the member's user_id, or changing an existing key's user_id to that member, returns 400 with the error code INVALID_REQUEST. Editing a key that is already bound to the member without changing its user_id still works.
  • A key whose owner is deactivated cannot be re-enabled. Setting disabled to false returns 400 with the error code INVALID_REQUEST. To hand the key to someone else, bind it to an active member or remove its user_id in the same request that enables it. That transfer is allowed on purpose.
  • An invitation to the organization cannot restore access. Redeeming one returns 403 with the error code MEMBER_DEACTIVATED, the invitation stays pending, and the membership stays deactivated. Reactivate the member from the identity provider instead.
  • Unused set-password links the organization issued for the member stop working. Deleting the member through SCIM retires them too.
  • No new set-password link can be issued while the member is deactivated: POST /members/{user_id}/set_password_link returns 400 with the error code INVALID_REQUEST, and the Members list offers no sign-in actions for the member.

Members Waiting to Join​

In AISIX Cloud, a user provisioned at an address outside the organization's verified domains is recorded as a member waiting to join. It has an id the IdP can use like any other user's, but no account is created or attached to it until the person joins.

AISIX sends an invitation to the address, in the name of the owner of the SCIM token:

  • The emails count toward the organization's hourly invitation email limit, which for directory sync is counted per organization. Over the limit, the invitation is still created without an email, and an administrator can resend it from the Pending invitations tab.
  • When the address already has a pending invitation, for example one an administrator sent from the dashboard, that invitation is used and no new email is sent. Directory sync never revokes an invitation it did not create.
  • A user provisioned with active: false gets no invitation until the IdP sets active: true.

The member joins, and becomes a regular member with the same SCIM id, in either of these ways:

  • The person accepts the invitation signed in to an account that uses the same email address. An invitation to that address that an administrator issued again, after the directory's own expired or was revoked, works as well.
  • The person connects the organization's SSO on the Connect page, and the NameID of their identity equals the externalId the directory sent. Configure the IdP to send the same identifier as both.

Either way, the member joins with the default role, externalId, IdP attributes, and team memberships the directory gave it, and an unused invitation that directory sync sent is revoked. If the account is a member of the organization already, the existing membership is kept, and the waiting member is removed.

Until then, changes from the IdP apply to the waiting member only:

  • active: false keeps the waiting member and its id, and revokes its invitation. active: true invites it again.
  • Changing its email address revokes the invitation to the old address and, for an active member, invites the new one. The new address must not belong to another SCIM user of the organization.
  • DELETE removes the waiting member and revokes the invitation that directory sync sent.

GET /Users lists waiting members alongside regular ones, filters included, and groups can reference them. They are listed in the Waiting to join section of the Members page, and by the GET /pending_members operation of the AISIX Enterprise / Cloud Admin API, which takes the same page and page_size parameters as GET /members. An organization that wants directory sync to provision members directly verifies its domains first.

Assign Roles to Synced Members​

SCIM groups sync to AISIX teams: pushing a group creates a team with the same name, and group membership changes add or remove team members.

Starting with control plane 1.11.0, a synced member's access comes from two places, and they add up:

  • The default role. Every member that directory sync provisions holds the Default role set on the Directory sync (SCIM) card, as an assignment with the source SCIM. It can be Restricted Member, Member, Admin, or a custom role, never Owner. A new organization starts with Restricted Member, and changing the default role takes a built-in admin or owner. Directory sync rewrites these assignments whenever the default role changes, and an assignment it made cannot be removed by hand.
  • The roles of the group's team. Give the synced team roles on its team page, and every member of the directory group holds them, for as long as the directory keeps them in the group. A member whom the IdP adds to or removes from the group gains or loses the team's roles when the IdP pushes the change.

Directory groups no longer map to roles directly. Use team roles instead: a role that used to be the target of a group mapping now belongs on the group's team.

A synced member can also hold roles assigned by hand or by SSO. Each mechanism maintains only its own assignments, so a role assigned by hand stays until someone removes it. Directory sync never assigns the owner role and never modifies an owner.

Combine with Single Sign-On​

Directory sync does not sign anyone in. To let synced members sign in to the dashboard through the same IdP, configure single sign-on. Send the same identifier as the SCIM externalId and the SAML NameID, so that a member waiting to join is activated when the person connects SSO. A synced member who signs in through SSO stays managed by directory sync. The roles that SSO assigns and the roles that directory sync assigns add up: neither replaces the other.

Use Synced Members for Attribution​

Directory sync creates the members; attribution works the same as for any member:

  1. Create or update an API key and set its owner to the synced member.
  2. Usage and budgets are attributed to that member, and member-scoped rate limit policies apply.

When the IdP deactivates the person, the keys stop authenticating at the gateway within seconds.

Cost attribution tags are not synced from the IdP. Directory sync neither reads nor writes a member's tags, so set them in the dashboard or through the Admin API, even on a member that directory sync manages.

Supported Endpoints​

The SCIM surface lives under /scim/v2 and answers in application/scim+json:

EndpointMethods
/UsersGET (list, eq filters on userName, emails.value, externalId), POST
/Users/{id}GET, PUT, PATCH, DELETE
/GroupsGET (list, eq filters on displayName, externalId), POST
/Groups/{id}GET, PUT, PATCH, DELETE
/ServiceProviderConfig, /ResourceTypes, /SchemasGET

PATCH follows the SCIM PatchOp shape, including the path forms Okta and Microsoft Entra ID emit (active, members[value eq "..."], and operations without a path). List responses page with startIndex and count (up to 200 per page). Attributes with no AISIX mapping, such as phone numbers or addresses, are accepted and ignored, so IdP attribute mappings do not need trimming.

Example: provision a user with curl:

curl -sS "${AISIX_SCIM_BASE_URL}/Users" \
-H "Authorization: Bearer ${AISIX_SCIM_TOKEN}" \
-H "Content-Type: application/scim+json" \
-d '{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName": "dev@example.com",
"displayName": "Developer One",
"emails": [
{
"value": "dev@example.com",
"primary": true
}
]
}'

Error Responses​

Every error on /scim/v2 is a SCIM error resource as defined in RFC 7644, so the identity provider can read it: Content-Type: application/scim+json, schemas set to ["urn:ietf:params:scim:api:messages:2.0:Error"], status as a string, detail, and scimType for some 400 and 409 causes. This includes errors returned before the request reaches the SCIM handlers:

  • 401 for a missing, invalid, revoked, or expired token, and 403 when the token cannot be used for the request, for example a token without the scim scope.
  • 408 for a body that is not sent within 30 seconds, and 413 for a body over 8 MiB.
  • 404 for a path or method that /scim/v2 does not serve.
  • 503 when the control plane cannot read the token or the organization, for example during a database stall. The request did not run, and can be sent again unchanged.
  • 503 with a Retry-After header while the control plane is being upgraded. Send the same request again after the time Retry-After gives.

Next Steps​

Continue with Connect a Gateway to attach a gateway to an environment. To investigate directory-driven changes later, use Logging and Auditing.