kafka:启用多种身份验证方法

dgiusagp  于 2021-06-06  发布在  Kafka
关注(0)|答案(1)|浏览(677)

过去我一直致力于为kafka客户机设置身份验证。我提到过:
https://kafka.apache.org/documentation/#security
https://docs.confluent.io/current/kafka/authentication_sasl/index.html#sasl-Kafka经纪人配置
以及其他链接。
正如文档中提到的,我们需要jaas配置文件来指定身份验证方法,我有一个如下所示:

KafkaClient {
    org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required
    LoginStringClaim_sub="admin";
};

它基本上为kafka客户机添加了oauth身份验证。
问题是-我可以在kafka代理上启用多个身份验证方法吗
我的意思是我可以在kafka上同时启用oauthbearer和普通身份验证,并让客户机通过这些方法中的任何一种进行身份验证。

cnh2zyt3

cnh2zyt31#

好吧,我找到了办法。
可以在代理上同时启用多个sasl机制,而每个客户机必须选择一种机制。
在jaas config文件中,我们必须指定多个登录模块的配置,如下所示:

KafkaServer {
  org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required
  LoginStringClaim_sub="admin";

  org.apache.kafka.common.security.plain.PlainLoginModule required
  username="admin"
  password="admin-secret"
  user_admin="admin-secret"
  user_alice="alice-secret";
};

然后我们必须在server.properties中启用sasl机制:


# List of enabled mechanisms, can be more than one

sasl.enabled.mechanisms=OAUTHBEARER,PLAIN

然后在server.properties中指定代理间通信的sasl安全协议和机制


# Configure SASL_SSL if SSL encryption is enabled, otherwise configure SASL_PLAINTEXT

security.inter.broker.protocol=SASL_SSL

# Configure the appropriate inter-broker protocol

sasl.mechanism.inter.broker.protocol=PLAIN

贷记-https://docs.confluent.io/current/kafka/authentication_sasl/index.html#enabling-多种sasl机制

相关问题