【发布时间】:2021-07-28 16:12:06
【问题描述】:
我们有一个启用 SSL 的 kafka 代理,并且通过 Keycloak 访问模式注册表。从外部机器,我可以使用 kafka-console-producer 发送数据,下面是我的配置。
ssl.properties:
security.protocol=SASL_SSL
ssl.truststore.location=truststore.jks
ssl.truststore.password=password
sasl.mechanism=PLAIN
jaas.conf:
KafkaClient
{
org.apache.kafka.common.security.plain.PlainLoginModule required
username="<user-name>"
password="<password>";
};
export KAFKA_OPTS="-Djavax.net.ssl.trustStore=truststore.jks -Djavax.net.ssl.trustStorePassword=password -Djava.security.auth.login.config=jaas.conf"
./kafka-console-producer --bootstrap-server broker-url:<external_port> --topic sample.data --producer.config ssl.properties
你好样本数据发送
我可以看到他们使用消费者
现在,对于模式注册表,我需要获取令牌,如下所示:
curl -k --data 'grant_type=password&client_id=schema-registry-client&username=username&password=password' https://<keycloakurl>/auth/realms/<namespace>/protocol/openid-connect/token
输出:
{"access_token":"<access_token>","expires_in":600,"refresh_expires_in":1800,"refresh_token":"<refresh_token>","token_type":"bearer","not-before-policy":0,"session_state":"4117e69c-afe9-43ae-9756-90b151f0b536","scope":"profile email"}
curl -k -H "Authorization: Bearer <access_token>"
https://<sc_url>/schemaregistry/subjects
输出:
["test.data-value"]
问题是,如何在 avro-console-producer 中使用 access_token ?我没有办法。
【问题讨论】:
标签: apache-kafka kafka-producer-api confluent-schema-registry