我使用sasl.jaas.config
属性为kafka设置了jaas配置。我想更新此配置并动态添加用户。
按照这个文档 - http://kafka.apache.org/11/documentation.html#dynamicbrokerconfigs,我们可以通过使用bin/kafka-configs.sh
来做到这一点。
我尝试使用以下命令更新sasl.jaas.config
:
bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-name 59 --alter --add-config sasl.jaas.config="KafkaServer {\n org.apache.kafka.common.security.plain.PlainLoginModule required\n username=\"myuser\"\n password=\"mypassword\";\n};\nClient {\n org.apache.zookeeper.server.auth.DigestLoginModule required\n username=\"myuser2\"\n password=\"mypassword2\";\n};"
但它给了我以下错误:
requirement failed: Invalid entity config: all configs to be added must be in the format "key=val"
如果我查看上面的列,它说sasl.jaas.config
属性的值的格式是(=)*
。这意味着什么?
应该如何传递'sasl.jaas.config'的值来动态更新jaas配置?
虽然可以动态更新sasl.jaas.config
以添加更多用户,但默认的Plain登录模块不适用于生产。
相反,您应该定义回调处理程序来处理用户的身份验证。这在Kafka Sasl Plain docs中有描述。
另一个需要更多工作(但提供更大灵活性)的选项是创建自己的登录模块。该过程在Can Kafka be provided with custom LoginModule to support LDAP?中描述
关于你得到的错误信息,这似乎是kafka-config.sh
工具的一个问题。它不期望配置值包含=
。您应该能够使用AdminClient API更新该配置。
我在JIRA中找不到现有问题所以创建了一个新问题:https://issues.apache.org/jira/browse/KAFKA-8010