|
| 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 %} |
0 commit comments