99 my_nifi_package.rego : |
1010 package my_nifi_package
1111
12- # TODO Parse or use a regular expression to validate the DN
13- nifi_node_proxy := "DC=local, DC=cluster, DC=svc, DC=test, DC=test-nifi-node-default-headless, DC=test-nifi-node-default-0, CN=generated certificate for pod"
12+ # FQDN of the NiFi nodes as regular expressions
13+ nodes_fqdn := [
14+ `local`,
15+ `cluster`,
16+ `svc`,
17+ `$NAMESPACE`,
18+ `test-nifi-node-default-headless`,
19+ `test-nifi-node-default-[0-9]+`,
20+ ]
21+
22+ domain_components = [concat("", [`DC=`, dc]) | some dc in nodes_fqdn]
23+ common_name = `CN=generated certificate for pod`
24+ subject_dn_fields = array.concat(domain_components, [common_name])
25+ node_subject_dn_pattern := concat("", ["^", concat(", ", subject_dn_fields), "$"])
26+
27+ is_nifi_node := regex.match(
28+ node_subject_dn_pattern,
29+ input.identity.name,
30+ )
31+
1432 nifi_reporting_task_user := "admin"
1533
1634 # Setting "resourceNotFound" to true results in the parent resource being evaluated for authorization,
82100 "allowed": true,
83101 "dumpCache": true
84102 } if {
85- input.identity.name == nifi_node_proxy
103+ is_nifi_node
86104 input.resource.id == "/proxy"
87105 }
88106
91109 "allowed": true,
92110 "dumpCache": true
93111 } if {
94- input.identity.name == nifi_node_proxy
112+ is_nifi_node
95113 startswith(input.resource.id, "/data/processors/")
96114 }
97115
@@ -100,12 +118,12 @@ data:
100118 user_groups := get_user_groups(input.identity.name)
101119
102120 get_user_groups(name) = groups if {
103- not startswith(name, nifi_node_proxy)
121+ not is_nifi_node
104122 groups_raw := data.stackable.opa.userinfo.v1.userInfoByUsername(name).groups
105123 groups := [trim(g, "/") | g := groups_raw[_]]
106124 }
107125
108126 # filter nifi_node_proxy calls to UIF
109127 get_user_groups(name) := [] if {
110- startswith(name, nifi_node_proxy)
128+ is_nifi_node
111129 }
0 commit comments