Skip to content

Add Mapping Configuration



POST /api/v1/login_mapping/field/add

Overview

Create a mapping from login attributes to role sets in the current Workspace.

Before You Call and Usage Steps

This group maintains Deployment Plan custom login attribute mappings for the current Workspace with isSystem=false. These differ from SAML mappings that bind identity providers by ssoUUID and from External/Inner system mappings. For the mapping to take effect, the Workspace must also enable isOpenCustomMappingRule; you can configure the toggle in Custom Mapping and verify the login policy. Saving/deleting only changes rules; it does not immediately change roles for existing members or revoke existing sessions. Subsequent shared LDAP/OIDC login flows rematch against the actual userinfo.

Matching uses top-level userinfo attributes: arrays are compared element by element using str(value), other values are compared by their Python string form, and fields and values use database equality semantics (case sensitivity/collation is determined by the deployment database). No regex, contains, or nested path extraction is performed; it is recommended to use only stable strings from the identity source. Roles from multiple matching rules are unioned and then filtered to available roles. When the Workspace custom toggle is enabled, it takes precedence over system rules: if there is a match, roles are usually reset; if there is no match, existing associations may be cleared; existing Owner roles have protection logic. Validate actual permissions with a dedicated test identity first; do not assume that roles at the next login are correct based solely on this HTTP success.

Only one active custom rule is allowed for sourceField+sourceValue in the same Workspace. A successful save returns only true and does not directly return the new UUID; afterward, verify by listing by source field/source value. The request can succeed after some invalid roles are filtered out; you must read back targetValues and roleInfos to confirm. [] is not a clear command; it returns 404 because there are no role records. If all matching records are soft-deleted roles, an empty set may be saved; do not treat it as a usable configuration.

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 enter: Obtain an OpenAPI Key with this operation permission from API Key Management in the target Workspace.

Body Request Parameters

Parameter Type Required Description
targetValues[*] string A single string, not the role display name; array elements are not subject to uniform strong typing constraints, and an incorrect shape may cause a 500 error. Do not submit objects or nested arrays.
Example: general
How to obtain or enter: Use a single role UUID visible in this Workspace or a system role identifier.
sourceField string Y Required string. It is recommended to use a non-empty value with the same case as the actual attribute; dot-path traversal/wildcards are not supported. The API declares ≤256 characters, but the current storage column is 128, so it is recommended to keep it ≤128 to avoid database errors; it is not automatically trimmed.
Allows null: False
Maximum length: 256
Example: department
How to obtain or enter: Obtain the actual top-level userinfo attribute name from the deployment LDAP/OIDC identity source administrator; you can cross-check it against the account attributes after a successful login.
sourceValue string Y Required string ≤256. Enter the original value exactly; it is not JSON array text or a regular expression. Empty strings are not currently rejected uniformly; whether they match depends on the actual userinfo.
Allows null: False
Maximum length: 256
Example: engineering
How to obtain or enter: Use the actual value of this attribute at login; for an array attribute, use the string value of one of its elements.
targetValues array Y Required array; a non-empty value is recommended. Unknown roles/roles from other Workspaces are filtered out; status 0/2 roles are retained, while if all do not exist/[] returns NotFoundRole. Status 2/deleted roles will not obtain valid permissions on subsequent logins; do not treat a save of true as meaning all roles are effective. The current Workspace custom entry does not apply the Owner restriction of External system mappings; clients should select target roles according to the actual authorization purpose.
Example: ["general"]
How to obtain or enter: Select a currently available role UUID/system role identifier from the target Workspace Role List, such as general/readOnly and custom role_.

Request Example

curl --request POST 'https://openapi.guance.com/api/v1/login_mapping/field/add' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"sourceField":"department","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; no new entity/UUID or role list is returned; verify again with list.
{
  "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 Resolution
406 ft.ParameterValidationFailed A request field is missing, or the field value violates the declared validation conditions Parameter parsing failed Verify the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError Invalid request JSON syntax Request JSON format error Correct the JSON according to content.reason, line, and column.
400 ft.JsonFormatError The top level of Body is not a JSON object Some JSON file format error Submit a complete object with sourceField/sourceValue/targetValues.
404 ft.SamlMappingFieldAlreadyExists A custom rule in the current Workspace already has the same sourceField+sourceValue combination (the current rule is excluded when modifying) A mapping field name and field value that are the same already exist in the Workspace Change the combination or modify the existing UUID; the historical error code is 404 and contains the Saml prefix, and is still used for this custom group.
404 ft.NotFoundRole No visible role record in the target/existing mapping role set matches, including []; it may also be triggered when old roles are parsed during single or batch deletion audit The specified role was not found or has been deleted First check against the current Workspace role list and mapping list. If unknown roles are partially mixed in, they will be filtered out; for historical empty/no-match sets, do not directly assume they can be deleted; an administrator must fix them before handling.
500 ft.InternalServerError An uncaught exception occurred in mapping/role/database storage or data formatting Internal error First use list to verify whether the rule has been saved and the final targetValues, then handle the specific field and retain traceId.

Feedback

Is this page helpful?