Skip to main content

How to Configure Row and Column Permissions Using API

1. Get Security Filter Information on Dataset

GET /api/data-source/{dsId}/security-filter

Parameters

NameLocationTypeMeaningRequiredRemarks
dsIdPathStringDataset IDYes
tokenHeaderStringLogin TokenYesToken needs to be obtained through login interface

Header Example

{
"token": "guanyuan token"
}

Response

{
"column":{
"enabled":true,
"rules":[]
},
"row":{
"enabled":false,
"rules":[],
"defaultRule":{
"ruleType":"HIDDEN"
}
},
"applyToOwner":false
}

Among them, ruleType currently supports 3 types

  • COLUMN (This is column-level permission, representing columns that cannot be viewed)

  • ADVANCED (Advanced mode row-level permission, similar to Threshold formula)

  • FREEFORM (Custom mode row-level permission, completely write SQL yourself)

2. Enable/Disable Row/Column Security Filter on Dataset, and Whether to Apply Security Filter to "Owner and Administrators"

POST api/data-source/{dsId}/security-filter/enable

Parameters

NameLocationTypeMeaningRequiredRemarks
tokenHeaderStringLogin TokenYesToken needs to be obtained through login interface
dsIdPathStringDataset IDYes
levelBodyStringLevelYesrow: row permission; column: column permission; applyToOwner: apply to administrators and Owner
enableBodyBooleanWhether to enableYestrue: enable; false: disable

POST Body Example

{
"level": "column",
"enable": true
}

Response

Returns equivalent to calling "Get Security Filter Information on Dataset" to get the latest Security Filter full information.

3. Row/Column Security Filter Rule on Dataset

3.1 Create Row/Column Security Filter Rule on Dataset

Apply existing permission rules to the dataset

POST api/data-source/{dsId}/security-filter/rules

Parameters

NameLocationTypeMeaningRequiredRemarks
tokenHeaderStringLogin tokenYes
dsIdPathStringDataset IDYes
ruleIdBodyStringRule IDYes
userAndGroupsBodyJSONUsers and user groupsYes
ruleTypeBodyStringRule typeYesCOLUMN: column-level ADVANCED: row-level FREEFORM: custom
commentBodyStringRemarks
forbiddenColumnsBodyJSONInvisible fieldsRequired if adding column permission
advancedBodyJSONRow permission rulesRequired if adding row permission
freeformBodyStringCustom rulesRequired if adding custom permission

POST Body Example

COLUMN Column-level Permission

{
"ruleId": "b4a956d66bd57464f8f050f4",
"userAndGroups": [
{
"relId": "b1766b1ac99bf4679a1bd762",
"name": "testUser",
"relType": "USER"
}
],
"ruleType": "COLUMN",
"comment":"testUser cannot read columns",
"forbiddenColumns": [
{
"fdId": "j9259851e2ac14152bd8e41d", /* fdId can be read from preview dataset in network preview */
"name": "city"
}
]
}

ADVANCED Row-level Permission

{
"userAndGroups": [
{
"relId": "b1766b1ac99bf4679a1bd762",
"name": "testUser",
"relType": "USER"
}
],
"ruleType": "ADVANCED",
"comment":"testUser cannot read rows",
"advanced": [
{
"type": "condition",
"not": false,
"value": {
"name": "2009年",
"fdType": "DOUBLE",
"fdId": "ea853c91",
"metaType": "METRIC",
"seqNo": 2,
"filterType": "GE",
"filterValue": [
"50",
""
],
"advFilter": null
}
}
]
}

FREEFORM Custom Permission

{
"userAndGroups": [
{
"relId": "b1766b1ac99bf4679a1bd762",
"name": "testUser",
"relType": "USER"
}
],
"ruleType": "FREEFORM",
"comment": "testUser canot read rows (freeform)",
"freeform": "[city] in 'hangzhou'"
}

Response

Returns equivalent to calling "Get Security Filter Information on Dataset" to get the latest Security Filter full information.

3.2 Modify Row/Column Security Filter Rule on Dataset

POST api/data-source/{dsId}/security-filter/rules/{ruleId}

Parameters

NameLocationTypeMeaningRequiredRemarks
tokenHeaderStringLogin tokenYes
dsIdPathStringDataset IDYes
ruleIdPathStringPermission rule IDYes
userAndGroupsBodyJSONUsers and user groupsYes
ruleTypeBodyStringRule typeYesCOLUMN: column-level ADVANCED: row-level FREEFORM: custom
commentBodyStringRemarks
forbiddenColumnsBodyJSONInvisible fieldsRequired if modifying column permission
advancedBodyJSONRow permission rulesRequired if modifying row permission
freeformBodyStringCustom rulesRequired if modifying custom permission

POST Body Example (FREEFORM)

{
"userAndGroups": [
{
"relId": "b1766b1ac99bf4679a1bd762",
"name": "testUser",
"relType": "USER"
},
{
"relId": "b1766b1ac99bf4679a1bd111",
"name": "User2",
"relType": "USER"
}
],
"ruleType": "FREEFORM",
"comment": "users canot read rows (freeform)",
"freeform": "[city] in 'hangzhou'"
}

Response

Returns equivalent to calling "Get Security Filter Information on Dataset" to get the latest Security Filter full information.

3.3 Delete Row/Column Security Filter Rule on Dataset

DELETE api/data-source/{dsId}/security-filter/rules/{ruleId}

Parameters

NameLocationTypeMeaningRequiredRemarks
tokenHeaderStringLogin tokenYes
dsIdPathStringDataset IDYes
ruleIdPathStringPermission rule IDYes

Response

Returns equivalent to calling "Get Security Filter Information on Dataset" to get the latest Security Filter full information.

4. Modify Default Rule on Dataset Column

POST api/data-source/{dsId}/security-filter/rules/row-level-default-rule

Parameters

NameLocationTypeMeaningRequiredRemarks
dsIdPathStringDataset IDYes

POST Body Example (FREEFORM)

{
"ruleType": "FREEFORM",
"comment": "default rule based on city",
"freeform": "[city] in 'hangzhou'"
}

Here, the supported ruleTypes are:

  • HIDDEN (Default rule, other users are invisible)

  • VISIBLE (All other users are visible, this is quite dangerous, needs warning!)

  • ADVANCED (Advanced mode column configuration, needs to read additional field advanced),

  • FREEFORM (Custom SQL mode, needs to read additional field freeform)

Response

Returns equivalent to calling "Get Security Filter Information on Dataset" to get the latest Security Filter full information.