diff --git a/stacks/airflow/trino.yaml b/stacks/airflow/trino.yaml index 489663e2..0fa4244d 100644 --- a/stacks/airflow/trino.yaml +++ b/stacks/airflow/trino.yaml @@ -14,6 +14,7 @@ spec: - authenticationClass: trino-users authorization: opa: + enableColumnMasking: false configMapName: opa package: trino tls: diff --git a/stacks/data-lakehouse-iceberg-trino-spark/trino.yaml b/stacks/data-lakehouse-iceberg-trino-spark/trino.yaml index 138fc23b..e8db21e9 100644 --- a/stacks/data-lakehouse-iceberg-trino-spark/trino.yaml +++ b/stacks/data-lakehouse-iceberg-trino-spark/trino.yaml @@ -14,6 +14,7 @@ spec: - authenticationClass: trino-users authorization: opa: + enableColumnMasking: false configMapName: opa package: trino coordinators: diff --git a/stacks/end-to-end-security/trino-regorules.yaml b/stacks/end-to-end-security/trino-regorules.yaml index 195c9e0a..fcec1f8f 100644 --- a/stacks/end-to-end-security/trino-regorules.yaml +++ b/stacks/end-to-end-security/trino-regorules.yaml @@ -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. @@ -1655,6 +1656,7 @@ data: # "schemaName": "schema", # "tableName": "table", # "columnName": "column", + # "columnType": "varchar", # }, # }, # }, @@ -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 diff --git a/stacks/trino-iceberg/trino.yaml b/stacks/trino-iceberg/trino.yaml index 975750bc..f613a0d2 100644 --- a/stacks/trino-iceberg/trino.yaml +++ b/stacks/trino-iceberg/trino.yaml @@ -14,6 +14,7 @@ spec: - authenticationClass: trino-users authorization: opa: + enableColumnMasking: false configMapName: opa package: trino coordinators: diff --git a/stacks/trino-superset-s3/trino.yaml b/stacks/trino-superset-s3/trino.yaml index 7a4de33c..aa85ebd1 100644 --- a/stacks/trino-superset-s3/trino.yaml +++ b/stacks/trino-superset-s3/trino.yaml @@ -14,6 +14,7 @@ spec: - authenticationClass: trino-users authorization: opa: + enableColumnMasking: false configMapName: opa package: trino coordinators: