|
9 | 9 | nifi.rego: | |
10 | 10 | package nifi |
11 | 11 |
|
| 12 | + nifi_node_proxy := "CN=generated certificate for pod" |
| 13 | + nifi_reporting_task_user := "admin" |
| 14 | +
|
12 | 15 | # Setting "resourceNotFound" to true results in the parent resource beingevaluated for authorization, |
13 | 16 | # e.g. the parent of a processor is the processor-group. |
14 | 17 | # If a resource is matched by a rego rule that is not the default the parent resource will be ignored. |
@@ -61,15 +64,47 @@ data: |
61 | 64 | group == "nifi-user" |
62 | 65 | } |
63 | 66 |
|
| 67 | + ### Reporting Task permissions (NiFi 1.x.x) |
| 68 | +
|
| 69 | + # Allow the reporting task user |
| 70 | + allow := { |
| 71 | + "allowed": true, |
| 72 | + "dumpCache": true |
| 73 | + } if { |
| 74 | + input.identity.name == nifi_reporting_task_user |
| 75 | + } |
| 76 | +
|
| 77 | + ### NiFi Node permissions |
| 78 | +
|
| 79 | + # NiFi Nodes need this permission to communicate with each other |
64 | 80 | allow := { |
65 | 81 | "allowed": true, |
66 | 82 | "dumpCache": true |
67 | 83 | } if { |
68 | | - input.identity.name == "CN=generated certificate for pod" |
| 84 | + input.identity.name == nifi_node_proxy |
69 | 85 | input.resource.id == "/proxy" |
70 | 86 | } |
71 | 87 |
|
72 | | - user_groups := user_groups if { |
73 | | - user_group_paths := data.stackable.opa.userinfo.v1.userInfoByUsername(input.identity.name).groups |
74 | | - user_groups := [ trim(user_group,"/") | user_group := user_group_paths[_] ] |
| 88 | + # Check processor queues |
| 89 | + allow := { |
| 90 | + "allowed": true, |
| 91 | + "dumpCache": true |
| 92 | + } if { |
| 93 | + input.identity.name == nifi_node_proxy |
| 94 | + startswith(input.resource.id, "/data/processors/") |
| 95 | + } |
| 96 | +
|
| 97 | + ### Helper functions |
| 98 | +
|
| 99 | + user_groups := get_user_groups(input.identity.name) |
| 100 | +
|
| 101 | + get_user_groups(name) = groups if { |
| 102 | + not startswith(name, nifi_node_proxy) |
| 103 | + groups_raw := data.stackable.opa.userinfo.v1.userInfoByUsername(name).groups |
| 104 | + groups := [trim(g, "/") | g := groups_raw[_]] |
| 105 | + } |
| 106 | +
|
| 107 | + # filter nifi_node_proxy calls to UIF |
| 108 | + get_user_groups(name) := [] if { |
| 109 | + startswith(name, nifi_node_proxy) |
75 | 110 | } |
0 commit comments