Skip to content

Commit d97652e

Browse files
authored
chore: Update rego-rules (#510)
1 parent 97f0e01 commit d97652e

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

tests/templates/kuttl/kerberos/12-rego-rules.txt.j2

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ data:
1111

1212
import rego.v1
1313

14-
default allow = false
14+
default allow := false
15+
default matches_identity(identity) := false
1516

1617
# HDFS authorizer
1718
allow if {
@@ -29,12 +30,40 @@ data:
2930
}
3031
}
3132

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+
3243
# Identity mentions group the user is part of (by looking up using the (long) userName)
3344
matches_identity(identity) if {
3445
some group in groups_for_user[input.callerUgi.userName]
3546
identity == concat("", ["group:", group])
3647
}
3748

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+
3867
# Resource mentions the file explicitly
3968
matches_resource(file, resource) if {
4069
resource == concat("", ["hdfs:file:", file])
@@ -63,6 +92,13 @@ data:
6392
"ro": ["ro"],
6493
}
6594

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+
66102
# To get a (hopefully complete) list of actions run "ack 'String operationName = '" in the hadoop source code
67103
action_for_operation := {
68104
# The "rename" operation will be actually called on both - the source and the target location.
@@ -183,6 +219,8 @@ data:
183219
"bob/access-hdfs.$NAMESPACE.svc.cluster.local@{{ test_scenario['values']['kerberos-realm'] }}": []
184220
}
185221

222+
groups_for_short_user_name := {}
223+
186224
acls := [
187225
{
188226
"identity": "group:admins",

0 commit comments

Comments
 (0)