You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/guides/56-security/masking-policy.md
+57-47Lines changed: 57 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,75 +6,85 @@ import EEFeature from '@site/src/components/EEFeature';
6
6
7
7
<EEFeaturefeatureName='MASKING POLICY'/>
8
8
9
-
A masking policy refers to rules and settings that control the display or access to sensitive data in a way that safeguards confidentiality while allowing authorized users to interact with the data. Databend enables you to define masking policies for displaying sensitive columns in a table, thus protecting confidential data while still permitting authorized roles to access specific parts of the data.
9
+
Masking policies protect sensitive data by dynamically transforming column values during query execution. They enable role-based access to confidential information—authorized users see actual data, while others see masked values.
10
10
11
-
To illustrate, consider a scenario where you want to present email addresses in a table exclusively to managers:
11
+
## How It Works
12
12
13
+
Masking policies apply transformation expressions to column data based on the current user's role:
14
+
15
+
**For managers:**
13
16
```sql
14
17
id | email |
15
18
---|-----------------|
16
19
2 | eric@example.com|
17
20
1 | sue@example.com |
18
21
```
19
22
20
-
And when non-manager users query the table, the email addresses would appear as:
21
-
23
+
**For other users:**
22
24
```sql
23
-
id|email |
24
-
--+---------+
25
-
2|*********|
26
-
1|*********|
25
+
id | email |
26
+
---|----------|
27
+
2 | *********|
28
+
1 | *********|
27
29
```
28
30
29
-
### Implementing Masking Policy
31
+
##Key Characteristics
30
32
31
-
Before creating a masking policy, make sure you have properly defined or planned user roles and their corresponding access privileges, as the policy's implementation relies on these roles to ensure secure and effective data masking. To manage Databend users and roles, see [User & Role](/sql/sql-commands/ddl/user/).
33
+
-**Query-time masking**: Policies transform data during SELECT operations only
34
+
-**Role-based**: Access rules depend on the current user's role using `current_role()`
35
+
-**Column-level**: Applied to specific table columns
36
+
-**Reusable**: One policy can protect multiple columns across different tables
37
+
-**Non-intrusive**: Original data remains unchanged in storage
32
38
33
-
Masking policies are applied to the columns of a table. To implement a masking policy for a specific column, you must first create the masking policy and then associate the policy to the intended column with the [ALTER TABLE COLUMN](/sql/sql-commands/ddl/table/alter-table-column) command. By establishing this association, the masking policy becomes tailored to the exact context where data privacy is paramount. It's important to note that a single masking policy can be associated with multiple columns, as long as they align with the same policy criteria. For commands used to manage masking policies in Databend, see [Masking Policy](/sql/sql-commands/ddl/mask-policy/).
39
+
## Read vs Write Operations
34
40
35
-
### Usage Examples
41
+
**Important**: Masking policies **only apply to read operations** (SELECT queries). Write operations (INSERT, UPDATE, DELETE) always process original, unmasked data. This ensures:
36
42
37
-
This example illustrates the process of setting up a masking policy to selectively reveal or mask sensitive data based on user roles.
43
+
- Query results are protected based on user permissions
44
+
- Applications can store and modify actual data values
45
+
- Data integrity is maintained in the underlying storage
0 commit comments