gpt4 book ai didi

authentication - 卡夫卡SASL : OAUTHBEARER and PLAIN simultaniously

转载 作者:行者123 更新时间:2023-12-04 04:32:05 28 4
gpt4 key购买 nike

我想做的是-

For Clients to Broker communication - use OAUTHBEARER authentication
For Broker to Broker communication - use PLAIN authentication

我有以下 JAAS 配置:

{
KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="inter"
password="inter-secret"
user_inter="inter-secret"
user_admin="YvNzcbmqhA0DfxjP";

org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required;
};

Client {
org.apache.zookeeper.server.auth.DigestLoginModule required
username="zookeeper"
password="zookeeper-secret";
};
}

我在 server.properties 中有以下配置:

sasl.enabled.mechanisms=PLAIN,OAUTHBEARER
sasl.mechanism.inter.broker.protocol=PLAIN
sasl.server.callback.handler.class=br.com.jairsjunior.security.oauthbearer.OauthAuthenticateValidatorCallbackHandler

但是如果启动 kafka 服务,我会看到如下错误:

used by: java.lang.IllegalArgumentException: Must supply exactly 1 non-null JAAS mechanism configuration (size was 2)
at org.apache.kafka.common.security.oauthbearer.internals.unsecured.OAuthBearerUnsecuredValidatorCallbackHandler.configure(OAuthBearerUnsecuredValidatorCallbackHandler.java:114)
at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:122)
... 17 more

表示kafka不允许指定多个JAAS机制配置。

那么我如何指定多个 JAAS 配置,并设置如下所示的身份验证机制:

CLient to Broker ----> OAUTHBEARER
Broker to Broker ----> PLAIN

谢谢!

最佳答案

我目前也在研究同时使用 plain 和 oauthbearer 的问题,我还没有解决这个问题,但是我通过以下方式解决了你的具体问题。这是我的 Jaas 配置:

internal.KafkaServer {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="admin"
password="admin-secret"
user_admin="admin-secret"
user_test="test";
};

external.KafkaServer {
org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required
};

Client {
org.apache.zookeeper.server.auth.DigestLoginModule required
username="username"
password="pw";
};

然后我按照以下方式在 server.properties 中进行设置:

  inter.broker.listener.name: INTERNAL 
sasl.mechanism.inter.broker.protocol: PLAIN
listener.security.protocol.map: INTERNAL:SASL_PLAINTEXT,EXTERNAL:SASL_SSL
listeners: "INTERNAL://0.0.0.0:9092,EXTERNAL://0.0.0.0:19092"
sasl.enabled.mechanisms: PLAIN,OAUTHBEARER

listener.name.external.oauthbearer.sasl.server.callback.handler.class: my.module.kafka.security.oauthbearer.OauthAuthenticateValidatorCallbackHandler
listener.name.external.oauthbearer.sasl.login.callback.handler.class: my.module.kafka.security.oauthbearer.OauthAuthenticateLoginCallbackHandler

当你这样做时,你不会得到你的错误。可悲的是,当经纪人想要建立外部连接时,我又遇到了另一个错误:

javax.security.auth.callback.UnsupportedCallbackException: Unrecognized SASL Login callback
at org.apache.kafka.common.security.authenticator.AbstractLogin$DefaultLoginCallbackHandler.handle(AbstractLogin.java:105)
at org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule.identifyToken(OAuthBearerLoginModule.java:316)
at org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule.login(OAuthBearerLoginModule.java:301)
... 32 more

kafka 经纪人似乎忽略了 oauthbearer 回调处理程序。这有点奇怪,因为当我将外部配置为唯一的监听器时,外部工作正常。

希望对您有所帮助!

关于authentication - 卡夫卡SASL : OAUTHBEARER and PLAIN simultaniously,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56378839/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com