-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsasl_Plain_SSL
258 lines (175 loc) · 7.16 KB
/
sasl_Plain_SSL
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
Simple Authentication and Security Layer (SASL) is a framework for authenticationand data security in Internet protocols. It decouples authentication mechanisms from application protocols, in theory allowing any authentication mechanism supported by SASL to be used in any application protocol that uses SASL.
Add below properties in server.properties:
listeners=PLAINTEXT://localhost:9093,SASL_SSL://localhost:9099
security.inter.broker.protocol=SASL_SSL
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
allow.everyone.if.no.acl.found=true
auto.create.topics.enable=true
broker.id=1
advertised.listeners=PLAINTEXT://localhost:9093,SASL_SSL://localhost:9099
advertised.host.name=localhost
auto.create.topics.enable=false
auto.leader.rebalance.enable=true
delete.topic.enable=true
controlled.shutdown.enable=true
ssl.keystore.location=/home/shamim/Confluent/security/kafka.server.keystore.jks
ssl.keystore.password=pwd
ssl.key.password=pwd
ssl.truststore.location=/home/shamim/Confluent/security/kafka.server.truststore.jks
ssl.truststore.password=pwd
listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SASL_SSL:SASL_SSL
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
num.partitions=1
num.recovery.threads.per.data.dir=1
log.flush.interval.messages=30000000
log.flush.interval.ms=1800000
log.retention.minutes=30
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
delete.topic.enable=true
zookeeper.connect=localhost:2181
zookeeper.connection.timeout.ms=6000
super.users=User:admin;User:ANONYMOUS
security.protocol=SASL_SSL
ssl.enabled.protocols=TLSv1.2,TLSv1.1,TLSv1
ssl.truststore.type=JKS
ssl.keystore.type = JKS
ssl.secure.random.implementation=SHA1PRNG
zookeeper.properties
dataDir=/tmp/zookeeper
clientPort=2181
maxClientCnxns=0
authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
requireClientAuthScheme=sasl
jaasLoginRenew=3600000
producer.properties
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
bootstrap.servers=localhost:9099
compression.type=none
sasl.kerberos.service.name=kafka
ssl.truststore.location=/home/shamim/Confluent/security/kafka.client.truststore.jks
ssl.truststore.password=pwd
ssl.enabled.protocols=TLSv1.2,TLSv1.1,TLSv1
ssl.truststore.type=JKS
ssl.truststore.type = JKS
kafka-rest_SASL_SSL.properties:
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.enabled.mechanisms=PLAIN
bootstrap.servers=SASL_SSL://localhost:9099
compression.type=none
client.sasl.mechanism=PLAIN
ssl.key.password = pwd
ssl.truststore.password = pwd
ssl.truststore.location = /home/shamim/Confluent/security/kafka.client.truststore.jks
ssl.keystore.location = /home/shamim/Confluent/security/kafka.server.keystore.jks
ssl.keystore.password=pwd
client.ssl.truststore.password = pwd
client.ssl.truststore.location = /home/shamim/Confluent/security/kafka.server.truststore.jks
client.security.protocol=SASL_SSL
client.ssl.protocol=TLSv1.1
client.ssl.enabled.protocols=TLSv1.2,TLSv1.1,TLSv1
client.ssl.keystore.type=JKS
client.ssl.truststore.type = JKS
client.connection.url=localhost:2181
host.name=localhost
ssl.protocol=TLSv1.1
ssl.enabled.protocols=TLSv1.2,TLSv1.1,TLSv1
ssl.keystore.type=JKS
ssl.truststore.type = JKS
client.ssl.key.password=pwd
listeners = https://localhost:8086
security.inter.broker.protocol = SSL
consumer.properties
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
compression.type=none
bootstrap.servers=localhost:2181
group.id=test-consumer-group
ssl.truststore.location=/home/shamim/Confluent/security/kafka.client.truststore.jks
ssl.truststore.password=pwd
ssl.enabled.protocols=TLSv1.2,TLSv1.1,TLSv1
ssl.truststore.type=JKS
ssl.truststore.type = JKS
Now are the most important files for making your server starting without any issue:
zookeeper_jaas.conf
Server {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret"
user_admin="admin-secret";
};
kafka_server.jaas
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret"
user_admin="admin-secret";
};
Client {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret";
};
kafka_client_jaas.conf
KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret";
};
kafka_rest_client_jaas.conf
KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret";
};
kafka_topic_client_jaas.conf
Client {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret";
};
kafka_acl_client_jaas.conf
Client {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret";
};
add the below properties in zookeeper-server-start
export KAFKA_OPTS="-Djava.security.auth.login.config=../etc/kafka/zookeeper_jaas.conf"
add the below properties in kafka-server-start
export KAFKA_OPTS="-Djava.security.auth.login.config=../etc/kafka/kafka_server_jaas.conf"
add the below properties in kafka-console-producer and kafka-console-consumer
export KAFKA_OPTS="-Djava.security.auth.login.config=../etc/kafka/kafka_client_jaas.conf"
add the below properties in kafka-rest-start file:
export KAFKAREST_OPTS="-Djava.security.auth.login.config=../etc/kafka/kafka_rest_client_jaas.conf"
add the below properties in kafka-topic
export KAFKA_OPTS="-Djava.security.auth.login.config=../etc/kafka/kafka_topic_client_jaas.conf"
add the below properties in kafka-acl
export KAFKA_OPTS="-Djava.security.auth.login.config=../etc/kafka/kafka_topic_client_jaas.conf"
now you can start server, zookeeper and producer and consumers.
./kafka-console-producer --broker-list localhost:9097 --producer.config ../etc/kafka/producer.properties --topic logs
./kafka-console-consumer --bootstrap-server localhost:9097 --topic logs --from-beginning --consumer.config ../etc/kafka/consumer.properties
start kafka -rest :
./kafka-rest-start ../etc/kafka-rest/kafka-rest_SASL_SSL.properties
create topic:
./kafka-topics --zookeeper localhost:2181 --create --topic test8 --partitions 1 --replication-factor 1
create acl:
./kafka-acls --add --allow-principal User:shamim --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --allow-host localhost --operation Read --operation Write --topic test8
dding ACLs for resource `Topic:test8`:
User:shamim has Allow permission for operations: Read from hosts: localhost
User:shamim has Allow permission for operations: Write from hosts: localhost
Current ACLs for resource `Topic:test8`:
User:shamim has Allow permission for operations: Read from hosts: localhost
User:shamim has Allow permission for operations: Write from hosts: localhost
Successfully able to produce, consume, get and post message.
Issue with LDAP auth:
https://docs.confluent.io/current/confluent-security-plugins/kafka/quickstart.html