Skip to content

Commit ee3eaaa

Browse files
committed
improve opa rules and fix reporting task access
1 parent 82bc969 commit ee3eaaa

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

tests/templates/kuttl/oidc-opa/25-opa-rego.yaml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ data:
99
nifi.rego: |
1010
package nifi
1111
12+
nifi_node_proxy := "CN=generated certificate for pod"
13+
nifi_reporting_task_user := "admin"
14+
1215
# Setting "resourceNotFound" to true results in the parent resource beingevaluated for authorization,
1316
# e.g. the parent of a processor is the processor-group.
1417
# 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:
6164
group == "nifi-user"
6265
}
6366
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
6480
allow := {
6581
"allowed": true,
6682
"dumpCache": true
6783
} if {
68-
input.identity.name == "CN=generated certificate for pod"
84+
input.identity.name == nifi_node_proxy
6985
input.resource.id == "/proxy"
7086
}
7187
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)
75110
}

0 commit comments

Comments
 (0)