How to Configure Row and Column Permissions with APIs
Get Security Filter Information on a Dataset
GET /api/data-source/{dsId}/security-filter
Parameters
| Name | Location | Type | Meaning | Required | Remarks |
| dsId | Path | String | Dataset id | Yes | |
| token | Header | String | Login Token | Yes | The token must be obtained through the login API |
Header Example
{
"token": "guanyuan token"
}
Response
{
"column":{
"enabled":true,
"rules":[]
},
"row":{
"enabled":false,
"rules":[],
"defaultRule":{
"ruleType":"HIDDEN"
}
},
"applyToOwner":false
}
Currently, ruleType supports three values:
- COLUMN: Column-level permission, representing columns that cannot be viewed.
- ADVANCED: Advanced row-level permission, similar to a Threshold formula.
- FREEFORM: Custom row-level permission, where you write SQL yourself.
Enable or Disable Row/Column Security Filter on a Dataset, and Whether to Apply Security Filter to Owner and Administrators
POST api/data-source/{dsId}/security-filter/enable
Parameters
| Name | Location | Type | Meaning | Required | Remarks |
| token | Header | String | Login Token | Yes | The token must be obtained through the login API |
| dsId | Path | String | Dataset id | Yes | |
| level | Body | String | Level | Yes | row: row permission; column: column permission; applyToOwner: apply to administrators and Owner |
| enable | Body | Boolean | Whether to enable | Yes | true: enable; false: disable |
POST Body Example
{
"level": "column",
"enable": true
}
Response
The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.
Row/Column Security Filter Rules on a Dataset
Create a Row/Column Security Filter Rule on a Dataset
Apply an existing permission rule to a dataset.
POST api/data-source/{dsId}/security-filter/rules
Parameters
| Name | Location | Type | Meaning | Required | Remarks |
| token | Header | String | Login token | Yes | |
| dsId | Path | String | Dataset id | Yes | |
| ruleId | Body | String | Rule id | Yes | |
| userAndGroups | Body | JSON | Users and user groups | Yes | |
| ruleType | Body | String | Rule type | Yes | COLUMN: column-level; ADVANCED: row-level; FREEFORM: custom |
| comment | Body | String | Comment | ||
| forbiddenColumns | Body | JSON | Invisible fields | Required when adding column permissions | |
| advanced | Body | JSON | Row permission rule | Required when adding row permissions | |
| freeform | Body | String | Custom rule | Required when adding custom permissions |
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 Network Preview when previewing the dataset */
"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 cannot read rows (freeform)",
"freeform": "[city] in 'hangzhou'"
}
Response
The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.
Modify a Row/Column Security Filter Rule on a Dataset
POST api/data-source/{dsId}/security-filter/rules/{ruleId}
Parameters
| Name | Location | Type | Meaning | Required | Remarks |
| token | Header | String | Login token | Yes | |
| dsId | Path | String | Dataset id | Yes | |
| ruleId | Path | String | Permission rule id | Yes | |
| userAndGroups | Body | JSON | Users and user groups | Yes | |
| ruleType | Body | String | Rule type | Yes | COLUMN: column-level; ADVANCED: row-level; FREEFORM: custom |
| comment | Body | String | Comment | ||
| forbiddenColumns | Body | JSON | Invisible fields | Required when modifying column permissions | |
| advanced | Body | JSON | Row permission rule | Required when modifying row permissions | |
| freeform | Body | String | Custom rule | Required when modifying custom permissions |
POST Body Example (FREEFORM)
{
"userAndGroups": [
{
"relId": "b1766b1ac99bf4679a1bd762",
"name": "testUser",
"relType": "USER"
},
{
"relId": "b1766b1ac99bf4679a1bd111",
"name": "User2",
"relType": "USER"
}
],
"ruleType": "FREEFORM",
"comment": "users cannot read rows (freeform)",
"freeform": "[city] in 'hangzhou'"
}
Response
The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.
Delete a Row/Column Security Filter Rule on a Dataset
DELETE api/data-source/{dsId}/security-filter/rules/{ruleId}
Parameters
| Name | Location | Type | Meaning | Required | Remarks |
| token | Header | String | Login token | Yes | |
| dsId | Path | String | Dataset id | Yes | |
| ruleId | Path | String | Permission rule id | Yes |
Response
The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.
Modify the Default Rule on Dataset Columns
POST api/data-source/{dsId}/security-filter/rules/row-level-default-rule
Parameters
| Name | Location | Type | Meaning | Required | Remarks |
| dsId | Path | String | Dataset id | Yes |
POST Body Example (FREEFORM)
{
"ruleType": "FREEFORM",
"comment": "default rule based on city",
"freeform": "[city] in 'hangzhou'"
}
Supported ruleType values are:
- HIDDEN: Default rule. Other users cannot see the columns.
- VISIBLE: All other users can see the columns. This is risky and requires a nearby prompt.
- ADVANCED: Advanced column configuration. The extra field
advancedneeds to be read. - FREEFORM: Custom SQL mode. The extra field
freeformneeds to be read.
Response
The response is equivalent to calling Get Security Filter Information on a Dataset to obtain the latest full Security Filter information.