11
11
12
12
import rego.v1
13
13
14
- default allow = false
14
+ default allow := false
15
+ default matches_identity(identity) := false
15
16
16
17
# HDFS authorizer
17
18
allow if {
@@ -29,12 +30,40 @@ data:
29
30
}
30
31
}
31
32
33
+ # Identity regex matches the (long) userName
34
+ matches_identity(identity) if {
35
+ match_entire(identity, concat("", ["userRegex:", input.callerUgi.userName]))
36
+ }
37
+
38
+ # Identity regex matches the shortUsername
39
+ matches_identity(identity) if {
40
+ match_entire(identity, concat("", ["shortUserRegex:", input.callerUgi.shortUserName]))
41
+ }
42
+
32
43
# Identity mentions group the user is part of (by looking up using the (long) userName)
33
44
matches_identity(identity) if {
34
45
some group in groups_for_user[input.callerUgi.userName]
35
46
identity == concat("", ["group:", group])
36
47
}
37
48
49
+ # Identity regex matches group the user is part of (by looking up using the (long) userName)
50
+ matches_identity(identity) if {
51
+ some group in groups_for_user[input.callerUgi.userName]
52
+ match_entire(identity, concat("", ["groupRegex:", group]))
53
+ }
54
+
55
+ # Identity mentions group the user is part of (by looking up using the shortUserName)
56
+ matches_identity(identity) if {
57
+ some group in groups_for_short_user_name[input.callerUgi.shortUserName]
58
+ identity == concat("", ["group:", group])
59
+ }
60
+
61
+ # Identity regex matches group the user is part of (by looking up using the shortUserName)
62
+ matches_identity(identity) if {
63
+ some group in groups_for_short_user_name[input.callerUgi.shortUserName]
64
+ match_entire(identity, concat("", ["groupRegex:", group]))
65
+ }
66
+
38
67
# Resource mentions the file explicitly
39
68
matches_resource(file, resource) if {
40
69
resource == concat("", ["hdfs:file:", file])
63
92
"ro": ["ro"],
64
93
}
65
94
95
+ match_entire(pattern, value) if {
96
+ # Add the anchors ^ and $
97
+ pattern_with_anchors := concat("", ["^", pattern, "$"])
98
+
99
+ regex.match(pattern_with_anchors, value)
100
+ }
101
+
66
102
# To get a (hopefully complete) list of actions run "ack 'String operationName = '" in the hadoop source code
67
103
action_for_operation := {
68
104
# The "rename" operation will be actually called on both - the source and the target location.
@@ -183,6 +219,8 @@ data:
183
219
"bob/access-hdfs.$NAMESPACE.svc.cluster.local@{{ test_scenario['values'] ['kerberos-realm'] }}": []
184
220
}
185
221
222
+ groups_for_short_user_name := {}
223
+
186
224
acls := [
187
225
{
188
226
"identity": "group:admins",
0 commit comments