Skip to content

Commit a3c5354

Browse files
committed
enable decision logs
1 parent 47b9502 commit a3c5354

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
# {% raw %}
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: hive-metastore-regorules
7+
labels:
8+
opa.stackable.tech/bundle: "true"
9+
data:
10+
actual_permissions.rego: |
11+
package hms
12+
13+
trino_user := "trino"
14+
spark_user := "spark"
15+
customer_analytics_db := "customer_analytics"
16+
compliance_analytics_db := "compliance_analytics"
17+
18+
default database_allow = false
19+
default table_allow = false
20+
default column_allow = false
21+
default partition_allow = false
22+
default user_allow = false
23+
24+
database_allow if {
25+
input.identity.username == spark_user
26+
input.resources.database.name == customer_analytics_db
27+
}
28+
29+
# Allow 'SELECT * FROM lakehouse.customer_analytics.customer'
30+
table_allow if {
31+
input.identity.username == spark_user
32+
input.resources.table.dbName == customer_analytics_db
33+
input.resources.table.tableName == "customer"
34+
input.privileges.readRequiredPriv[0].priv == "SELECT"
35+
}
36+
37+
# Allow: 'CREATE TABLE IF NOT EXISTS lakehouse.customer_analytics.spark_report AS SELECT c_birth_country, count(*) FROM ..'
38+
table_allow if {
39+
input.identity.username == spark_user
40+
input.resources.table.dbName == customer_analytics_db
41+
input.resources.table.tableName == "spark_report"
42+
input.privileges.writeRequiredPriv[0].priv == "CREATE"
43+
}
44+
45+
# Trino
46+
database_allow if {
47+
input.identity.username == trino_user
48+
}
49+
50+
table_allow if {
51+
input.identity.username == trino_user
52+
}
53+
54+
column_allow if {
55+
input.identity.username == trino_user
56+
}
57+
58+
partition_allow if {
59+
input.identity.username == trino_user
60+
}
61+
62+
user_allow if {
63+
input.identity.username == trino_user
64+
}
65+
66+
# {% endraw %}

stacks/end-to-end-security/hive-metastore.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ spec:
77
image:
88
productVersion: 4.0.0
99
clusterConfig:
10+
authorization:
11+
opa:
12+
configMapName: opa
13+
package: hms
1014
database:
1115
connString: jdbc:postgresql://postgresql-hive-iceberg:5432/hive
1216
credentialsSecret: postgres-credentials

stacks/end-to-end-security/opa.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ spec:
2525
logging:
2626
containers:
2727
opa:
28+
console:
29+
level: INFO
30+
file:
31+
level: INFO
2832
loggers:
2933
decision:
3034
level: INFO

0 commit comments

Comments
 (0)