title: Kafka: enabling multiple authentication methods
body: <p>I have worked on setting the authentication for Kafka clients in past. I have I have refered: </p>
  
  <ol>
  <li><a href="https://kafka.apache.org/documentation/#security" rel="nofollow noreferrer">https://kafka.apache.org/documentation/#security</a></li>
  <li><a href="https://docs.confluent.io/current/kafka/authentication_sasl/index.html#sasl-configuration-for-kafka-brokers" rel="nofollow noreferrer">https://docs.confluent.io/current/kafka/authentication_sasl/index.html#sasl-configuration-for-kafka-brokers</a></li>
  </ol>
  
  <p>And other links as well.</p>
  
  <p>As mentioned in docs we need to have jaas configuration file to specify the authentication method, I had one like below:</p>
  
  <pre><code>KafkaClient {
      org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required
      LoginStringClaim_sub="admin";
  };
  </code></pre>
  
  <p>Which basically adds the OAuth authentication for kafka clients.</p>
  
  <p>The question is - <strong>can I have multiple authentication methods enabled on kafka broker</strong></p>
  
  <p>I mean can I enable both OAuthBearer and PLAIN authentication on Kafka, and let the <strong>client</strong> authenticate by any one of these methods.</p>