Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stacks/airflow/trino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec:
- authenticationClass: trino-users
authorization:
opa:
enableColumnMasking: false
configMapName: opa
package: trino
tls:
Expand Down
1 change: 1 addition & 0 deletions stacks/data-lakehouse-iceberg-trino-spark/trino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec:
- authenticationClass: trino-users
authorization:
opa:
enableColumnMasking: false
configMapName: opa
package: trino
coordinators:
Expand Down
86 changes: 86 additions & 0 deletions stacks/end-to-end-security/trino-regorules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,7 @@ data:
# - allow
# - batch
# - columnMask
# - batchColumnMasks
# - rowFilters
# These rules use the rules and functions in requested_permission.rego
# and actual_permissions.rego to calculate the result.
Expand Down Expand Up @@ -1655,6 +1656,7 @@ data:
# "schemaName": "schema",
# "tableName": "table",
# "columnName": "column",
# "columnType": "varchar",
# },
# },
# },
Expand Down Expand Up @@ -1709,6 +1711,90 @@ data:
column_mask := {"expression": column.mask}
}

# METADATA
# description: |
# Entry point for fetching column masks in batch, configured in the
# Trino property `opa.policy.batch-column-masking-uri`.
#
# The input has the following form:
#
# {
# "action": {
# "operation": "GetColumnMasks",
# "filterResources": [{
# "column": {
# "catalogName": "catalog",
# "schemaName": "schema",
# "tableName": "table",
# "columnName": "column",
# "columnType": "varchar",
# }},
# {"column": ...},
# ...
# ],
# },
# "context": {
# "identity": {
# "groups": ["group1", ...],
# "user": "username",
# },
# "softwareStack": {"trinoVersion": "455"},
# }
# }
#
# The batchColumnMask rule queries the column constraints in the
# Trino policies for each of the resources in the "filterResources"
# list of the request and returns a list of viewExpressions, containing
# the column mask if any set and optionally the identity for the mask
# evaluation, and the index of the corresponding resource in the
# "filterResources" list of the request.
# A column mask is an SQL expression,
# e.g. "'XXX-XX-' + substring(credit_card, -4)".
# entrypoint: true
batchColumnMasks contains column_mask if {
input.action.operation == "GetColumnMask"
some index, resource in input.action.filterResources

column := column_constraints(
resource.column.catalogName,
resource.column.schemaName,
resource.column.tableName,
resource.column.columnName,
)

is_string(column.mask)
is_string(column.mask_environment.user)

column_mask := {
"index": index,
"viewExpression": {
"expression": column.mask,
"identity": column.mask_environment.user,
},
}
}

batchColumnMasks contains column_mask if {
input.action.operation == "GetColumnMask"
some index, resource in input.action.filterResources

column := column_constraints(
resource.column.catalogName,
resource.column.schemaName,
resource.column.tableName,
resource.column.columnName,
)

is_string(column.mask)
is_null(column.mask_environment.user)

column_mask := {
"index": index,
"viewExpression": {"expression": column.mask},
}
}


# METADATA
# description: |
# Entry point for fetching row filters, configured in the Trino
Expand Down
1 change: 1 addition & 0 deletions stacks/trino-iceberg/trino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec:
- authenticationClass: trino-users
authorization:
opa:
enableColumnMasking: false
configMapName: opa
package: trino
coordinators:
Expand Down
1 change: 1 addition & 0 deletions stacks/trino-superset-s3/trino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec:
- authenticationClass: trino-users
authorization:
opa:
enableColumnMasking: false
configMapName: opa
package: trino
coordinators:
Expand Down