Skip to content

Commit

Permalink
fix: Add missing OPA rules for Trino batched API (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer authored Jan 2, 2024
1 parent 0bb9692 commit 60856ef
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
12 changes: 12 additions & 0 deletions stacks/data-lakehouse-iceberg-trino-spark/trino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,28 @@ data:
trino.rego: |
package trino
import future.keywords.in
default allow = false
# Allow non-batched access
allow {
is_admin
}
# Allow batched access
extended[i] {
some i
input.action.filterResources[i]
is_admin
}
# Corner case: filtering columns is done with a single table item, and many columns inside
extended[i] {
some i
input.action.operation == "FilterColumns"
count(input.action.filterResources) == 1
input.action.filterResources[0].table.columns[i]
is_admin
}
is_admin() {
input.context.identity.user == "admin"
Expand Down
26 changes: 22 additions & 4 deletions stacks/dual-hive-hdfs-s3/trino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ metadata:
name: trino
spec:
image:
productVersion: "414"
productVersion: "428"
clusterConfig:
authorization:
opa:
Expand Down Expand Up @@ -101,12 +101,30 @@ metadata:
data:
trino.rego: |
package trino
import future.keywords.in
default allow = false
# Allow non-batched access
allow {
input.context.identity.user == "admin"
is_admin
}
# Allow batched access
extended[i] {
some i
input.action.filterResources[i]
is_admin
}
# Corner case: filtering columns is done with a single table item, and many columns inside
extended[i] {
some i
input.action.operation == "FilterColumns"
count(input.action.filterResources) == 1
input.action.filterResources[0].table.columns[i]
is_admin
}
allow {
input.context.identity.user == "demo"
is_admin() {
input.context.identity.user == "admin"
}
10 changes: 10 additions & 0 deletions stacks/trino-iceberg/trino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,24 @@ data:
default allow = false
# Allow non-batched access
allow {
is_admin
}
# Allow batched access
extended[i] {
some i
input.action.filterResources[i]
is_admin
}
# Corner case: filtering columns is done with a single table item, and many columns inside
extended[i] {
some i
input.action.operation == "FilterColumns"
count(input.action.filterResources) == 1
input.action.filterResources[0].table.columns[i]
is_admin
}
is_admin() {
input.context.identity.user == "admin"
Expand Down
10 changes: 10 additions & 0 deletions stacks/trino-superset-s3/trino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,24 @@ data:
default allow = false
# Allow non-batched access
allow {
is_admin
}
# Allow batched access
extended[i] {
some i
input.action.filterResources[i]
is_admin
}
# Corner case: filtering columns is done with a single table item, and many columns inside
extended[i] {
some i
input.action.operation == "FilterColumns"
count(input.action.filterResources) == 1
input.action.filterResources[0].table.columns[i]
is_admin
}
is_admin() {
input.context.identity.user == "admin"
Expand Down

0 comments on commit 60856ef

Please sign in to comment.