Mickael Maison commented on KAFKA-4180:

Hi Guillaume,

You can achieve that by having a custom login module. 
Create a class that extends PlainLoginModule and override initialize() with 
your credentials logic. For example you can set your client properties as a 
ThreadLocal, retrieve the client.id in initialize() and based on that load 
different credentials. You can set the username and password by calling 
respectively getPublicCredentials().add() and getPrivateCredentials().add() on 
the subject.Then update your jaas file to point to your class instead of the 
default PlainLoginModule class. 

> Shared authentification with multiple actives Kafka producers/consumers
> -----------------------------------------------------------------------
>                 Key: KAFKA-4180
>                 URL: https://issues.apache.org/jira/browse/KAFKA-4180
>             Project: Kafka
>          Issue Type: Bug
>          Components: producer , security
>    Affects Versions:
>            Reporter: Guillaume Grossetie
>              Labels: authentication, jaas, loginmodule, plain, producer, 
> sasl, user
> I'm using Kafka with an SASL authentication on the client:
> {code:title=kafka_client_jaas.conf|borderStyle=solid}
> KafkaClient {
>     org.apache.kafka.common.security.plain.PlainLoginModule required
>     username="guillaume"
>     password="secret";
> };
> {code}
> When using multiple Kafka producers the authentification is shared [1]. In 
> other words it's not currently possible to have multiple Kafka producers in a 
> JVM process.
> Am I missing something ? How can I have multiple active Kafka producers with 
> different credentials ?
> My use case is that I have an application that send messages to multiples 
> clusters (one cluster for logs, one cluster for metrics, one cluster for 
> business data).
> [1] 
> https://github.com/apache/kafka/blob/69ebf6f7be2fc0e471ebd5b7a166468017ff2651/clients/src/main/java/org/apache/kafka/common/security/authenticator/LoginManager.java#L35

This message was sent by Atlassian JIRA

Reply via email to