Skip to content

Get user permission list

This document is automatically generated based on https://github.com/authing/authing-docs-factory based on https://api-explorer.genauth.ai V3 API, and is consistent with API parameters and return results. If the document description is incorrect, please refer to V3 API.

Description

This interface is used to query the permission data of certain users in certain permission spaces.

Our authentication interface has multiple authentication scenarios, the difference lies in the parameter list that can be passed in the scenario and the different forms of output parameters. When you need to query all permissions of certain users, you can use this interface,

Note

The interface provides two array-type input parameters userIds and namespaceCodes to support batch query (Note: namespaceCodes is optional).

Scenario Example

If your business scenario is that after a user logs in, he can see all the documents, personnel information, equipment information and other resources that he can access or perform other operations on, then you can call this interface to query all the user's permissions after the user logs in.

Request example

Query a single user permission list example

Note: In the return parameters of this interface, the data resource permissions of the tree type are returned in the path way

  • Input parameter
json
{
  "userIds": ["6301ceaxxxxxxxxxxx27478"]
}
  • Output parameter
json
{
  "statusCode": 200,
  "message": "Operation successful",
  "apiCode": 20001,
  "data": {
    "userPermissionList": [
      {
        "userId": "6301ceaxxxxxxxxxxx27478",
        "namespaceCode": "examplePermissionNamespace",
        "resourceList": [
          {
            "resourceCode": "strCode",
            "resourceType": "STRING",
            "strAuthorize": {
              "value": "Example string resource",
              "actions": ["read", "post", "get", "write"]
            }
          },
          {
            "resourceCode": "arrayCode",
            "resourceType": "ARRAY",
            "arrAuthorize": {
              "values": ["Example data resource 1", "Example data resource 2"],
              "actions": ["read", "post", "get", "write"]
            }
          },
          {
            "resourceCode": "treeCode",
            "resourceType": "TREE",
            "treeAuthorize": {
              "authList": [
                {
                  "nodePath": "/treeChildrenCode/treeChildrenCode1",
                  "nodeActions": ["read", "get"],
                  "nodeName": "treeChildrenName1",
                  "nodeValue": "treeChildrenValue1"
                },
                {
                  "nodePath": "/treeChildrenCode/treeChildrenCode2",
                  "nodeActions": ["read", "get"],
                  "nodeName": "treeChildrenName2",
                  "nodeValue": "treeChildrenValue2"
                },
                {
                  "nodePath": "/treeChildrenCode/treeChildrenCode3",
                  "nodeActions": ["read"],
                  "nodeName": "treeChildrenName3",
                  "nodeValue": "treeChildrenValue3"
                }
              ]
            }
          }
        ]
      }
    ]
  }
}

Example of querying multiple user permission lists

  • Input parameters
json
{
  "userIds": ["6301ceaxxxxxxxxxxx27478", "6121ceaxxxxxxxxxxx27312"]
}
  • Output parameters
json
{
  "statusCode": 200,
  "message": "Operation successful",
  "apiCode": 20001,
  "data": {
    "userPermissionList": [
      {
        "userId": "6301ceaxxxxxxxxxxx27478",
        "namespaceCode": "examplePermissionNamespace1",
        "resourceList": [
          {
            "resourceCode": "strCode",
            "resourceType": "STRING",
            "strAuthorize": {
              "value": "Example string resource",
              "actions": ["read", "post", "get", "write"]
            }
          }
        ]
      },
      {
        "userId": "6121ceaxxxxxxxxxxx27312",
        "namespaceCode": "examplePermissionNamespace2",
        "resourceList": [
          {
            "resourceCode": "arrayCode",
            "resourceType": "ARRAY",
            "arrAuthorize": {
              "values": [
                "Example array resource 1",
                "Example array resource 2"
              ],
              "actions": ["read", "post", "get", "write"]
            }
          }
        ]
      }
    ]
  }
}

Example of querying the permission list of multiple users in multiple permission spaces

  • Input parameters
json
{
  "userIds": ["6301ceaxxxxxxxxxxx27478", "6121ceaxxxxxxxxxxx27312"],
  "namespaceCodes": [
    "examplePermissionNamespace1",
    "examplePermissionNamespace2"
  ]
}
  • Output parameters
json
{
  "statusCode": 200,
  "message": "Operation successful",
  "apiCode": 20001,
  "data": {
    "userPermissionList": [
      {
        "userId": "6301ceaxxxxxxxxxxxx27478",
        "namespaceCode": "examplePermissionNamespace1",
        "resourceList": [
          {
            "resourceCode": "strCode1",
            "resourceType": "STRING",
            "strAuthorize": {
              "value": "Example string resource",
              "actions": ["read", "post", "get", "write"]
            }
          }
        ]
      },
      {
        "userId": "6121ceaxxxxxxxxxxx27312",
        "namespaceCode": "examplePermissionNamespace2",
        "resourceList": [
          {
            "resourceCode": "arrayCode",
            "resourceType": "ARRAY",
            "arrAuthorize": {
              "values": [
                "Example array resource 1",
                "Example array resource 2"
              ],
              "actions": ["read", "post", "get", "write"]
            }
          }
        ]
      }
    ]
  }
}

Method name

ManagementClient.getUserPermissionList

Request parameters

NameTypeIs it required?Default valueDescriptionSample value
userIdsstring[]yes-user ID list["6301ceaxxxxxxxxxxx27478"]
namespaceCodesstring[]no-permission space code list["examplePermissionNamespace1"]

Sample code

ts
import { ManagementClient, Models } from "authing-node-sdk";

// Initialize ManagementClient
const managementClient = new ManagementClient({
  // Need to be replaced with your GenAuth Access Key ID
  accessKeyId: "GEN_AUTH_ACCESS_KEY_ID",
  // Need to be replaced with your GenAuth Access Key Secret
  accessKeySecret: "GEN_AUTH_ACCESS_KEY_SECRET",
  // If you are a private deployment customer, you need to set the GenAuth service domain name
  // host: 'https://api.your-authing-service.com'
});

(async () => {
  const result = await managementClient.getUserPermissionList({
    userIds: ["6229ffaxxxxxxxxcade3e3d9", "6229ffaxxxxxxxxcade3e3d9"],
    namespaceCodes: [
      "examplePermissionNamespace1",
      "examplePermissionNamespace2",
    ],
  });

  console.log(JSON.stringify(result, null, 2));
})();

Request response

Type: GetUserPermissionListRespDto

NameTypeDescription
statusCodenumberBusiness status code, which can be used to determine whether the operation is successful. 200 means success.
messagestringdescription
apiCodenumberSegmented error code, through which the specific error type can be obtained (not returned for successful requests). For a detailed list of error codes, please see: API Code List
data<a GetUserPermissionListDataDtoResponse data

Sample result:

json
{
  "statusCode": 200,
  "message": "Operation successful",
  "apiCode": 20001,
  "data": {
    "userPermissionList": {
      "userId": "6301cexxxxxxxxxxxxxxxxx78",
      "namespaceCode": "examplePermissionNamespace",
      "resourceList": {
        "resourceCode": "resourceCode",
        "resourceType": "STRING",
        "strAuthorize": {
          "value": "Example string resource Value",
          "actions": "[\"read\",\"get\"]"
        },
        "arrAuthorize": {
          "values": "[\"value0\",\"value1\"]",
          "actions": "[\"read\",\"get\"]"
        },
        "treeAuthorize": {
          "authList": {
            "nodePath": "/treeCode1/treeCode11",
            "nodeName": "Example tree resource node name",
            "nodeActions": "[\"read\",\"get\"]",
            "nodeValue": "Example tree resource node Value"
          }
        }
      }
    }
  }
}

Data structure

GetUserPermissionListDataDto

NameTypeIs it requiredDescriptionSample value
userPermissionListarrayYesUser permission list Nested type: <a UserPermissionListDto.

UserPermissionListDto

NameTypeIs it required?DescriptionSample value
userIdstringyesUser ID authorized by data policy6301cexxxxxxxxxxxxxxxxx78
namespaceCodestringyesPermission space Code authorized by data policyexamplePermissionNamespace
resourceListarraynoList of all data policy resources of the user under the permission space Nested type: <a OpenResource.

OpenResource

NameTypeIs it required?DescriptionSample value
resourceCodestringYesData resource Code authorized under the data policyresourceCode
resourceTypestringYesData resource type authorized under the data policy. Currently, it supports three types: tree structure (TREE), string (STRING), and array (ARRAY). Different structures are returned according to different types.
- STRING: string type result StrAuthorize
- ARRAY: array type ArrayAuthorize
- TREE: tree type TreeAuthorize
TREE
strAuthorizeNoString resource of data policy Nested type: <a StrAuthorize.
arrAuthorizeNoArray resource of data policy Nested type: <a ArrayAuthorize.
treeAuthorizeNoTree resource of data policy Nested type: <a TreeAuthorize.

StrAuthorize

NameTypeIs it required?DescriptionSample value
valuestringYesString resource ValueSample string resource Value
actionsarrayYesString resource action list["read","get"]

ArrayAuthorize

NameTypeIs it required?DescriptionSample value
valuesarrayYesArray resource Value list["value0","value1"]
actionsarrayYesArray resource action list["read","get"]

TreeAuthorize

NameTypeIs it requiredDescriptionSample value
authListarrayYesTree resource authorization list Nested type: <a TreeAuthBo.

TreeAuthBo

NameTypeIs it required?DescriptionSample value
nodePathstringyesTree resource node path/treeCode1/treeCode11
nodeNamestringyesTree resource node nameSample tree resource node name
nodeActionsarrayyesTree resource node operation permission list["read","get"]
nodeValuestringnoTree resource node ValueSample tree resource node Value

Agent infrastructure for identity, memory, and web action.