-
Notifications
You must be signed in to change notification settings - Fork 3
/
kafka_authz.rego
44 lines (36 loc) · 978 Bytes
/
kafka_authz.rego
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package kafka.authz
# Kafka authorize request
import input as kafka_request
default allow = false
topics = {
"X" : {
"Read" : ["saslconsumer"],
"Write" : ["saslproducer"],
"Describe" : ["saslconsumer", "saslproducer"],
}
}
groups = {
"ssl-sasl-host" : {
"Read" : ["saslconsumer"] ,
"Write" : ["saslconsumer"] ,
"Describe" : ["saslconsumer", "saslproducer"],
}
}
super_users = [
"kafka"
]
allow {
super_users[_] = kafka_request.session.principal.name
}
allow {
kafka_request.resource.resourceType.name = "Topic"
kafka_request.session.principal.principalType = "User"
topics[kafka_request.resource.name][kafka_request.operation.name][_] =
kafka_request.session.principal.name
}
allow {
kafka_request.resource.resourceType.name = "Group"
kafka_request.session.principal.principalType = "User"
groups[kafka_request.resource.name][kafka_request.operation.name][_] =
kafka_request.session.principal.name
}