Skip to content

Get Switch Status Information



GET /api/v1/login_mapping/switch/get

Overview

Query the site system login mapping switch and application mode.

Prerequisites and Usage Steps

Requires External credentials with r or w permissions. Do not pass a request body or Query; reads the site-level system mapping configuration. When no configuration exists, the defaults are isDisable=true and type=GlobalValid. Here, GlobalValid is the mode default and does not indicate that the feature is enabled. The response is not the custom mapping switch of a specific Workspace.

Request Headers

Parameter Name Type Required Description
X-Df-SVersion string Signature version for the original path and request body; you cannot omit it and continue to use the algorithm on this page.
Example: v20240417
How to obtain or fill in: The example on this page uses this fixed version and is paired with the example signing algorithm.
X-Df-Access-Key string Y Read endpoints accept r or w credentials; write endpoints require w credentials.
Example: <external-access-key>
How to obtain or fill in: Assigned by the site administrator as an External API AK; a Workspace OpenAPI Key cannot be used.
X-Df-Signature string Y Compute HMAC-SHA256 over the uppercase method, nonce, original full path, timestamp, and original UTF-8 request body joined by spaces, then take the hex digest.
Example: <hmac-sha256-hex>
How to obtain or fill in: Calculate using the paired SK according to External API Signature Authentication; see the complete runnable template below.
X-Df-Timestamp string Y Must be within the signature validity time window configured for the site; do not reuse the example time.
Example: 1785427200
How to obtain or fill in: At send time, use str(int(time.time())) to generate the current Unix seconds string.
X-Df-Nonce string Y Temporary nonce; when resending after a failure, also generate a new value and recompute the signature.
Example: 97d275ee9f774315a7885ba7347acbd9
How to obtain or fill in: Regenerate uuid.uuid4().hex for each request.

Additional Parameter Notes

For authentication, see External API Signature Authentication. This module manages the site system login mapping (isSystem=1) and is used by third-party logins such as OIDC/LDAP that use the shared login mapping chain; it is not a Workspace custom mapping or a standalone SAML settings API. Saving the configuration does not immediately recalculate all existing user permissions in bulk; processing according to the mode occurs only on subsequent related logins.

When the system mapping is enabled and the target Workspace has custom mapping disabled: ValidOnFirstLogin applies system rules only to accounts that have no historical direct Workspace association (history includes deleted associations); it is not equivalent to determining only whether an account is newly created this time. GlobalValid replaces direct roles according to the rules on each related login, and when there is no match, it can remove direct member/role relationships. Append only adds matching system roles and does not clear existing direct relationships when there is no match. If a Workspace enables custom mapping, that Workspace preferentially executes replacement/no-match cleanup according to custom rules and cannot apply the retention semantics of the system Append mode or first-login mode. Turning off the system switch does not also turn off Workspace custom rules. Existing direct Owner roles are retained during matching and are not newly granted Owner through this module.

Request Example

import hashlib
import hmac
import json
import time
import uuid
from urllib.parse import urlencode
from urllib.request import Request, urlopen
from urllib.error import HTTPError, URLError

# Replace with the target site address and the External API AK/SK assigned by the administrator.
server = "https://external-api.guance.com"
access_key = "<external-access-key>"
secret_key = "<external-secret-key>"
method = 'GET'
path = '/api/v1/login_mapping/switch/get'
query = {}
data = None
full_path = path + ("?" + urlencode(query) if query else "")
body = "" if data is None else json.dumps(data, ensure_ascii=False, separators=(",", ":"))
timestamp = str(int(time.time()))
nonce = uuid.uuid4().hex
string_to_sign = " ".join([method, nonce, full_path, timestamp, body])
signature = hmac.new(secret_key.encode("utf-8"), string_to_sign.encode("utf-8"), hashlib.sha256).hexdigest()
headers = {
    "X-Df-Access-Key": access_key,
    "X-Df-Timestamp": timestamp,
    "X-Df-Nonce": nonce,
    "X-Df-Signature": signature,
    "X-Df-SVersion": "v20240417",
}
if data is not None:
    headers["Content-Type"] = "application/json"
request = Request(server + full_path, data=None if data is None else body.encode("utf-8"), headers=headers, method=method)
try:
    with urlopen(request, timeout=30) as result:
        payload = json.loads(result.read().decode("utf-8"))
except HTTPError as error:
    print("HTTP", error.code, error.read().decode("utf-8"))  # Handle by errorCode, content, and traceId; do not output AK/SK.
    raise SystemExit(1)
except (URLError, TimeoutError):
    print('读取失败,可退避后重新签名重试,保留traceId及查询条件。')
    raise SystemExit(1)
print(json.dumps(payload, ensure_ascii=False, indent=2))

Response

HTTP 200, unified application/json envelope; External does not automatically inject declaration, and list pagination is in content.pageInfo.

Field Type Description
content.isDisable boolean or integer true/1 disabled, false/0 enabled; an empty write request may persist the historical value as integer 0.
content.type string System mapping mode: ValidOnFirstLogin, GlobalValid, or Append; defaults to GlobalValid if omitted.
{
  "code": 200,
  "content": {
    "isDisable": true,
    "type": "GlobalValid"
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

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

Confirmed rule and request errors are listed in the table. Ordinary database/cache/audit exceptions ultimately result in 500 ft.InternalServerError; the configuration may already have been committed before subsequent errors occur, so read the current state first and then retry.

HTTP Status errorCode Trigger Condition Message or Response Description Handling
500 ft.InternalServerError Database, site configuration cache, audit, or unhandled historical data exceptions Internal error Retain the traceId and first read the rule or switch to confirm the current state; the database and cache/audit are not in the same transaction, so an error does not prove that nothing was saved.

Feedback

Is this page helpful?