代码之家  ›  专栏  ›  技术社区  ›  user439407

使用带有SASL\u明文的spring kafka tests@EmbeddedKafka broker时出现登录错误

  •  0
  • user439407  · 技术社区  · 5 年前

    我正在尝试使用springkafka测试和@EmbeddedBroker编写一个集成测试,并使用SASL\u明文验证。

    @EmbeddedKafka(partitions = 1,
        ports = 8088,
        brokerProperties = {"security.inter.broker.protocol=SASL_PLAINTEXT",
                "listeners=SASL_PLAINTEXT://localhost:8088",
                "advertised.listeners=SASL_PLAINTEXT://localhost:8088",
                "sasl.enabled.mechanisms=PLAIN",
                "sasl.mechanism.inter.broker.protocol=PLAIN",
        },
        bootstrapServersProperty = "mybootstrapproperty",
        topics = "mytopic")
    

    我有一个静态部分来加载java.security.auth验证.登录名.config属性:

        static {
        System.setProperty("java.security.auth.login.config", "/var/tmp/kafka_jaas.conf");
    }
    

    该文件的内容:

        KafkaServer {
       org.apache.kafka.common.security.plain.PlainLoginModule required
       username="brokeradmin"
       password="password"
       user_admin="admin_password"
       user_user="secret";
    };
    

    当我使用此配置运行时,它无法启动嵌入式kafka代理,并且我在日志中收到以下一系列消息:

        2020-07-01 13:36:17.549 [ INFO] 12198 --- [r-0-send-thread] org.apache.kafka.common.network.Selector : [Controller id=0, targetBrokerId=0] Failed authentication with localhost/127.0.0.1 (Authentication failed: Invalid username or password)
    2020-07-01 13:36:17.549 [ERROR] 12198 --- [r-0-send-thread] org.apache.kafka.clients.NetworkClient   : [Controller id=0, targetBrokerId=0] Connection to node 0 (localhost/127.0.0.1:8088) failed authentication due to: Authentication failed: Invalid username or password
    2020-07-01 13:36:17.549 [ WARN] 12198 --- [r-0-send-thread] kafka.controller.RequestSendThread       : [RequestSendThread controllerId=0] Controller 0's connection to broker localhost:8088 (id: 0 rack: null) was unsuccessful
    

    0 回复  |  直到 5 年前