【问题标题】:Transiently kerberos authentication failure with Kafka client applicationKafka 客户端应用程序的瞬时 kerberos 身份验证失败
【发布时间】:2018-11-20 10:29:14
【问题描述】:

我正在使用最新版本的 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


    【解决方案1】:

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

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

    【讨论】:

    • 我使用 TicketCache 而不是明确指定 ketab 和 principal。
    • 使用 TicketCache 是否意味着您不必在 jaas 文件中指定主体和密钥表?它的文档在哪里说您不必指定?
    • 它只会暂时失败。此外,当我遇到连接到 Kafka 的问题时,我使用票证缓存的其他应用程序也可以正常工作。
    • 你确定你的票在 kafka 客户端失败的确切时间仍然有效吗?您如何续订机票?
    • 是的票是有效的,因为我试图强制获取新票,然后它也失败了。
    【解决方案2】:

    我想建议您的几个选择,

    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

    希望这会有所帮助:)

    【讨论】:

    • 感谢您的帮助。我没有完全掌握#2。客户端主体通常采用“/host@REALM”的形式,所以这个服务名称在哪里出现。如果它是用于 kafka 服务器的,那么是的,我拥有“HTTP/host@realm”形式的主体,并在 kafka 服务器和消费者/生产者中设置了 -Dsasl.kerberos.service.name=HTTP。我错过了什么吗?
    • sasl.kerberos.service.name 应该与服务 kafka 的主体名称匹配。通常它被设置为 kafka/host@RELM。它拥有操纵kafka的完全权利。如果您使用任何其他服务名称(没有完全操作 kafka 的权限),那么尝试对 kafka 主题进行任何更改都会失败。
    • Kafka 服务器也使用 HTTP/host@REALM 运行。 (已在 kafka 服务器和生产者/消费者中将此属性设置为 HTTP)
    • 我对此不是 100% 确定,但是使用 HTTP 运行代理可能会由于我的第二点原因而导致问题。尝试将您的原则更改为 kafka(如果您已为 kafka 创建了原则)
    • 您缺少 java 属性 -Djava.security.auth.login.config=/path/to/jaas.conf
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-27
    • 2023-03-22
    • 1970-01-01
    • 2015-02-17
    • 2019-01-08
    • 2016-02-22
    • 2015-04-27
    相关资源
    最近更新 更多