title: Kafka authentication with Jaas config
body: <p>I have set up my Kafka jaas config as an external bean in my spring boot application to read my configuration from my application.yaml file.</p>
  <p>But I am facing an error reading my jaas keytab file from my yaml file.</p>
  <p>Error faced</p>
  <pre><code>Caused by: javax.security.auth.login.LoginException: Could not login: the client is being asked for a password, but the Kafka client code does not currently support obtaining a password from the user. not available to garner  authentication information from the user
  at jdk.security.auth/com.sun.security.auth.module.Krb5LoginModule.promptForPass(Krb5LoginModule.java:918) ~[jdk.security.auth:na]
  at jdk.security.auth/com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Krb5LoginModule.java:738) ~[jdk.security.auth:na]
  at jdk.security.auth/com.sun.security.auth.module.Krb5LoginModule.login(Krb5LoginModule.java:592) ~[jdk.security.auth:na]
  at java.base/javax.security.auth.login.LoginContext.invoke(LoginContext.java:726) ~[na:na]
  at java.base/javax.security.auth.login.LoginContext$4.run(LoginContext.java:665) ~[na:na]
  at java.base/javax.security.auth.login.LoginContext$4.run(LoginContext.java:663) ~[na:na]
  at java.base/java.security.AccessController.doPrivileged(AccessController.java:691) ~[na:na]
  at java.base/javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:663) ~[na:na]
  at java.base/javax.security.auth.login.LoginContext.login(LoginContext.java:574) ~[na:na]
  at org.apache.kafka.common.security.authenticator.AbstractLogin.login(AbstractLogin.java:60) ~[kafka-clients-2.5.1.jar:na]
  at org.apache.kafka.common.security.kerberos.KerberosLogin.login(KerberosLogin.java:103) ~[kafka-clients-2.5.1.jar:na]
  at org.apache.kafka.common.security.authenticator.LoginManager.&lt;init&gt;(LoginManager.java:62) ~[kafka-clients-2.5.1.jar:na]
  at org.apache.kafka.common.security.authenticator.LoginManager.acquireLoginManager(LoginManager.java:112) ~[kafka-clients-2.5.1.jar:na]
  at org.apache.kafka.common.network.SaslChannelBuilder.configure(SaslChannelBuilder.java:158) ~[kafka-clients-2.5.1.jar:na]
  </code></pre>
  <p>This is how I have configured my jaas</p>
  <p>KafkaJaasConfigurationProperty.java</p>
  <pre><code>@Component
  @ConfigurationProperties(prefix = &quot;kafka.jaas&quot;)
  @Getter
  @Setter
  public class KafkaJaasConfigurationProperties {
    private Map&lt;String, String&gt; options;
  }
  </code></pre>
  <p>application.yml</p>
  <pre><code>kafka:
   jaas:
    options:
     useKeyTab: true
     keytab: keytab-value
     storeKey: true
     debug: true
     serviceName: kafka
     principal: pricipal-value
  </code></pre>
  <p>KafkaJaasConfigurationBean.java</p>
  <pre><code>@Bean
  public KafkaJaasLoginModuleInitializer jaasConfig(
      KafkaJaasConfigurationProperties kafkaJaasConfigurationProperties
  ) throws IOException {
      var jaasConfig = new KafkaJaasLoginModuleInitializer();
      jaasConfig.setControlFlag(KafkaJaasLoginModuleInitializer.ControlFlag.REQUIRED);
      jaasConfig.setOptions(kafkaJaasConfigurationProperties.getOptions());
      return jaasConfig;
  }
  </code></pre>
  <p>Any help will be appreciated. Thanks!</p>