|
| 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 | + hive-metastore.rego: | |
| 11 | + package hive_iceberg |
| 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 | + ### SPARK ### |
| 25 | + # These rules are tailored for the create-spark-report job. |
| 26 | +
|
| 27 | + # Allow the spark user access to the 'customer_analytics_db' |
| 28 | + database_allow if { |
| 29 | + input.identity.username == spark_user |
| 30 | + input.resources.database.name == customer_analytics_db |
| 31 | + } |
| 32 | +
|
| 33 | + # Allow the 'SELECT * FROM lakehouse.customer_analytics.customer' query in create-spark-report |
| 34 | + table_allow if { |
| 35 | + input.identity.username == spark_user |
| 36 | + input.resources.table.dbName == customer_analytics_db |
| 37 | + input.resources.table.tableName == "customer" |
| 38 | + input.privileges.readRequiredPriv[0].priv == "SELECT" |
| 39 | + } |
| 40 | +
|
| 41 | + # Allow the 'CREATE TABLE IF NOT EXISTS lakehouse.customer_analytics.spark_report AS SELECT c_birth_country, count(*) FROM ..' |
| 42 | + # query in create-spark-report |
| 43 | + table_allow if { |
| 44 | + input.identity.username == spark_user |
| 45 | + input.resources.table.dbName == customer_analytics_db |
| 46 | + input.resources.table.tableName == "spark_report" |
| 47 | + input.privileges.writeRequiredPriv[0].priv == "CREATE" |
| 48 | + } |
| 49 | +
|
| 50 | + ### TRINO ### |
| 51 | + # We allow everything here for the technical trino user in order to still do data exploration |
| 52 | + database_allow if { |
| 53 | + input.identity.username == trino_user |
| 54 | + } |
| 55 | +
|
| 56 | + table_allow if { |
| 57 | + input.identity.username == trino_user |
| 58 | + } |
| 59 | +
|
| 60 | + column_allow if { |
| 61 | + input.identity.username == trino_user |
| 62 | + } |
| 63 | +
|
| 64 | + partition_allow if { |
| 65 | + input.identity.username == trino_user |
| 66 | + } |
| 67 | +
|
| 68 | + user_allow if { |
| 69 | + input.identity.username == trino_user |
| 70 | + } |
| 71 | +
|
| 72 | +# {% endraw %} |
0 commit comments