|
| 1 | +--- |
| 2 | +apiVersion: v1 |
| 3 | +kind: ConfigMap |
| 4 | +metadata: |
| 5 | + name: airflow-rules |
| 6 | + labels: |
| 7 | + opa.stackable.tech/bundle: "true" |
| 8 | +data: |
| 9 | + airflow.rego: | |
| 10 | + package airflow |
| 11 | +
|
| 12 | + # Default deny everything. Only the rules below should permit anything. |
| 13 | + default is_authorized_configuration := false |
| 14 | + default is_authorized_connection := false |
| 15 | + default is_authorized_dag := false |
| 16 | + default is_authorized_pool := false |
| 17 | + default is_authorized_variable := false |
| 18 | + default is_authorized_view := false |
| 19 | + default is_authorized_custom_view := false |
| 20 | + default is_authorized_backfill := false |
| 21 | + default is_authorized_asset := false |
| 22 | + default is_authorized_asset_alias := false |
| 23 | +
|
| 24 | + # Allow-all for the "airflow" admin so the operator can bootstrap the |
| 25 | + # cluster (creating the admin user, syncing example DAGs, etc). |
| 26 | + is_authorized_configuration if input.user.name == "airflow" |
| 27 | + is_authorized_connection if input.user.name == "airflow" |
| 28 | + is_authorized_dag if input.user.name == "airflow" |
| 29 | + is_authorized_pool if input.user.name == "airflow" |
| 30 | + is_authorized_variable if input.user.name == "airflow" |
| 31 | + is_authorized_view if input.user.name == "airflow" |
| 32 | + is_authorized_custom_view if input.user.name == "airflow" |
| 33 | + is_authorized_backfill if input.user.name == "airflow" |
| 34 | + is_authorized_asset if input.user.name == "airflow" |
| 35 | + is_authorized_asset_alias if input.user.name == "airflow" |
| 36 | +
|
| 37 | + # jane.doe is OPA-allow-all - same shape as the airflow admin block above. |
| 38 | + # Intentionally broad: the goal of this test is to isolate the FAB |
| 39 | + # filter/listing layer. Any 403 we see for jane.doe must therefore come |
| 40 | + # from FAB (the layer with the bug), not from OPA denying some auxiliary |
| 41 | + # check (is_authorized_view, is_authorized_configuration, ...) that the |
| 42 | + # listing endpoint also performs. |
| 43 | + # |
| 44 | + # With this rule + Admin role: both layers say yes -> test passes. |
| 45 | + # With this rule + Public role: OPA says yes everywhere, FAB's |
| 46 | + # unoverridden get_authorized_dag_ids says no -> 403 -> test fails (bug). |
| 47 | + is_authorized_configuration if input.user.name == "jane.doe" |
| 48 | + is_authorized_connection if input.user.name == "jane.doe" |
| 49 | + is_authorized_dag if input.user.name == "jane.doe" |
| 50 | + is_authorized_pool if input.user.name == "jane.doe" |
| 51 | + is_authorized_variable if input.user.name == "jane.doe" |
| 52 | + is_authorized_view if input.user.name == "jane.doe" |
| 53 | + is_authorized_custom_view if input.user.name == "jane.doe" |
| 54 | + is_authorized_backfill if input.user.name == "jane.doe" |
| 55 | + is_authorized_asset if input.user.name == "jane.doe" |
| 56 | + is_authorized_asset_alias if input.user.name == "jane.doe" |
0 commit comments