Kafka 客户端应用程序暂时 kerberos 身份验证失败

问题描述 投票:0回答:2

我正在使用最新版本的 kafka,在通过 SASL_PLAINTEXT 将我的消费者/生产者(控制台)客户端连接到 kafka 代理时暂时面临问题。

这是我的jaas配置文件

KafkaClient {
   com.sun.security.auth.module.Krb5LoginModule required
   useTicketCache=true;
};

这是我传递的java属性:

-Djavax.security.auth.useSubjectCredsOnly=false
-Dsecurity.protocol=SASL_PLAINTEXT
-Dsasl.kerberos.service.name=HTTP
-Dsasl.mechanism=GSSAPI

这是我遇到的例外:

Caused by: org.apache.kafka.common.KafkaException: javax.security.auth.login.LoginException: Could not login: the client is being asked for a password, but the Kafka client code does not currently support obtaining a password from the user. not available to garner  authentication information from the user
        at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:127)
        at org.apache.kafka.common.network.ChannelBuilders.create(ChannelBuilders.java:140)
        at org.apache.kafka.common.network.ChannelBuilders.clientChannelBuilder(ChannelBuilders.java:65)
        at org.apache.kafka.clients.ClientUtils.createChannelBuilder(ClientUtils.java:88)
        at org.apache.kafka.clients.consumer.KafkaConsumer.<init>(KafkaConsumer.java:710)
        ... 33 more
Caused by: javax.security.auth.login.LoginException: Could not login: the client is being asked for a password, but the Kafka client code does not currently support obtaining a password from the user. not available to garner  authentication information from the user
        at com.sun.security.auth.module.Krb5LoginModule.promptForPass(Krb5LoginModule.java:940)

有人可以帮忙吗?

authentication apache-kafka kerberos jaas
2个回答
0
投票

您的 jaas 文件中缺少主体和密钥表。

参见 https://kafka.apache.org/documentation/#security_sasl_kerberos


0
投票

我想建议你几个选择,

  1. 列出当前已兑现的keytab中的所有原理并检查是否正确。

  2. 如果您尝试使用 KAFKA 以外的任何原则对主题进行任何更改,该操作将会失败。设置-Dsasl.kerberos.service.name=kafka

  3. 尝试设置

    export KAFKA_OPTS="-Djava.security.auth.login.config=/path/to/jaas.conf 
    -Djava.security.krb5.conf=/etc/krb5.conf -Dsun.security.krb5.debug=true"

  4. 如果使用控制台生产者/消费者,则需要提供生产者配置/消费者配置。在 Producer.properties 或 Consumer.properties 中配置以下属性。

    security.protocol=SASL_PLAINTEXT (or SASL_SSL)
    sasl.mechanism=GSSAPI (or PLAIN)

    对于控制台消费者使用如下命令

    kafka-console-consumer --bootstrap-server host:9092 --consumer.config /path/to/consumer.properties --topic Topic
    

希望这会有所帮助:)

© www.soinside.com 2019 - 2024. All rights reserved.