Skip to content

Create Mapping Rule



POST /api/v1/sso_mapping/field/add

Overview

Create an attribute-to-role mapping for a specified SSO provider.

Prerequisites and Usage Steps

This API group maps login attributes of a specific SSO provider to roles in the current workspace, which differs from custom_login_mapping and system mappings of LDAP/OIDC in the Deployment Plan. Creating a rule does not automatically enable mapping: you must enable isOpenSAMLMapping (set_disable in this group) for the corresponding SSO configuration, and the SSO configuration itself must also be enabled.

Attribute name matching is compared in lowercase; values are not regex/contains matches. String arrays are matched value by value; non-array objects, numbers, null, and so on are first converted to strings via json.dumps, while array elements are not uniformly converted to strings, so prefer string attributes and string arrays that are stable in the identity source. Multiple matching roles are combined as a union. After SSO mapping is enabled, no rules or no matches can prevent the account from entering this space, and old associations are removed during subsequent logins/switches; this is not simply appending a default role. After writing, workspace and member caches are refreshed asynchronously, which may affect subsequent access of existing SSO sessions; it cannot be promised to take effect only at the next login.

Field/value combinations are unique within the same provider. Creation does not automatically turn on the provider's mapping switch; configure and verify the rules first, then enable. Success returns only true; retrieve the new UUID from the list afterwards. Input roles are filtered; after saving, verify targetValues/roleInfos against ssoInfo. After submission, a cache refresh task is dispatched; if dispatch fails, a 500 may occur but the rule has already been saved; do not blindly create it again. This API group does not send SSO configuration change emails, and does not apply the needNotify parameter of the shared SSO create/modify to this page.

Request Headers

Parameter Type Required Description
DF-API-KEY string Y OpenAPI authentication credential for the workspace.
Example: <DF-API-KEY>
How to obtain or fill in: Obtain an OpenAPI Key with this operation permission from the API Key management of the target workspace.

Body Request Parameters

Parameter Type Required Description
targetValues[*] string String, not a display name; do not submit nested objects; the shape of the current element is not subject to uniform strong type validation.
Example: general
How to obtain or fill in: A single role UUID/system identifier visible in this workspace.
ssoUUID string Y Required for creation as declared; although declared optional for modification, the implementation overwrites the old ssoUUID with the omitted value None, so a normal submission may cause a database 500, and the current/new target must be explicitly backfilled. Current create/modify does not enforce validation that the SSO exists or belongs to the workspace; a successful save does not prove the target is valid; do not submit UUIDs from other workspaces or fake UUIDs.
Allowed null: False
Max length: 48
Example: sso_example
How to obtain or fill in: Get the provider uuid of the current workspace from the SSO configuration list; choose SAML or OIDC according to the actual configuration.
sourceField string Y Required; a non-empty value is recommended. During matching, field names are case-insensitive, but the same-name check is still determined by the database's equality semantics; dot paths are not supported. Creation declares no uniform length limit, modification is ≤256, and the storage column is 256; keep both ≤256.
Allowed null: False
Example: groups
How to obtain or fill in: Obtain the real top-level attribute field name from the identity provider administrator.
sourceValue string Y Required; a non-empty value is recommended. Not a wildcard/regex; creation declares no length, modification is ≤256, and the storage column is 256; keep all ≤256.
Allowed null: False
Example: engineering
How to obtain or fill in: Take the real string of the attribute or a single element in the string array; do not fill in the full array text.
targetValues array Y Required array; a non-empty value is recommended. Some unknown/cross-workspace roles are filtered out; statuses 0/2 are retained; [] or no visible records at all reports NotFoundRole. Saving with status 2 does not guarantee current availability; the list's roleInfos shows only 0. When all targets are soft-deleted but the records still exist, they may be filtered into an empty set and not treated as a valid mapping.
Example: ["general"]
How to obtain or fill in: Get visible role identifiers from the current workspace role list, such as general/readOnly/custom role_.

Request Example

curl --request POST 'https://openapi.guance.com/api/v1/sso_mapping/field/add' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"ssoUUID":"sso_example","sourceField":"groups","sourceValue":"engineering","targetValues":["general"]}'

Response

HTTP 200, application/json. The example below shows the main fields that can be read directly.

Field Type Description
content boolean true on success; the mapping entity or login result is not returned.
{
  "code": 200,
  "content": true,
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

For authentication, rate limiting, and common request errors, see Common Error Definitions.

HTTP Status errorCode Trigger Condition Message or Response Description Handling
406 ft.ParameterValidationFailed Request field missing, or field value violates the declared validation conditions Parameter parsing failed Check the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError Request JSON syntax is invalid Request JSON format error Fix the JSON according to content.reason, line, and column.
400 ft.JsonFormatError The top level of the Body is not an object Some json file format errors Submit a complete ssoUUID/sourceField/sourceValue/targetValues object.
404 ft.SamlMappingFieldAlreadyExists A non-deleted mapping with the same ssoUUID+sourceField+sourceValue already exists in this workspace (modification excludes itself) A mapping field name and field value that are identical already exist in the workspace Use a new combination or update the existing UUID; note that the HTTP status is 404.
404 ft.NotFoundRole The input roles or the old mapping target set contains no role records visible in this workspace, including []; modify/delete audits may also trigger this The specified role was not found or the role has been deleted Verify the current input/old targets from the role list; do not treat an empty set as a successful clear; ask an administrator to repair historical bad rules before proceeding.
500 ft.InternalServerError An uncaught exception occurs in the saved JSON shape, the database, or task dispatch after submission Internal error The database may have been committed while the cache task dispatch failed; first read back the rule/SSO switch from the list, then proceed, and keep the traceId.

Feedback

Is this page helpful?