title: Grant access to ANONYMOUS user on Kafka and Zookeeper SASL/PLAIN server
body: <p>I'm running a basic (1 broker) Kafka (<code>v2.3.0</code>) and Zookeeper instance on my machine with a working SASL/PLAINTEXT authentication mechanism and I'm trying consume topic as ANONYMOUS user. I'm using these configs:</p>
  <p><strong>server.properties</strong></p>
  <pre><code>broker.id=0
  group.initial.rebalance.delay.ms=0
  log.dirs=/tmp/kafka-logs
  log.retention.check.interval.ms=300000
  log.retention.hours=168
  log.segment.bytes=1073741824
  num.io.threads=8
  num.network.threads=3
  num.partitions=1
  num.recovery.threads.per.data.dir=1
  offsets.topic.replication.factor=1
  socket.receive.buffer.bytes=102400
  socket.request.max.bytes=104857600
  socket.send.buffer.bytes=102400
  transaction.state.log.min.isr=1
  transaction.state.log.replication.factor=1
  zookeeper.connect=localhost:2181
  zookeeper.connection.timeout.ms=6000
  
  
  security.inter.broker.protocol=SASL_PLAINTEXT
  sasl.mechanism.inter.broker.protocol=PLAIN
  sasl.enabled.mechanisms=PLAIN
  authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
  allow.everyone.if.no.acl.found=true
  auto.create.topics.enable=false
  
  listeners=SASL_PLAINTEXT://localhost:9092
  advertised.listeners=SASL_PLAINTEXT://localhost:9092
  
  advertised.host.name=localhost
  delete.topic.enable=true
  zookeeper.set.acl=true
  super.users=User:admin
  </code></pre>
  <p><strong>zookeeper.properties</strong></p>
  <pre><code>dataDir=/tmp/zookeeper0607
  clientPort=2181
  maxClientCnxns=0
  
  authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
  requireClientAuthScheme=sasl
  jaasLoginRenew=3600000
  </code></pre>
  <p><strong>consumer.properties</strong></p>
  <pre><code>bootstrap.servers=localhost:9092
  group.id=test-consumer-group
  </code></pre>
  <p>I've grant the user ANONYMOUS using this command:
  <code>bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:ANONYMOUS --consumer --group '*' --topic 'test'</code></p>
  <p>But when I try to consume (or produce) topic <em>test</em> running kafka-consumer script it returns the following error:</p>
  <pre><code>[2020-07-06 15:36:37,525] WARN [Consumer clientId=consumer-1, groupId=test-consumer-group] Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected (org.apache.kafka.clients.NetworkClient)
  </code></pre>
  <p>And the Kafka server logs:</p>
  <pre><code>[2020-07-06 15:36:39,784] INFO [SocketServer brokerId=0] Failed authentication with /127.0.0.1 (Unexpected Kafka request of type METADATA during SASL handshake.) (org.apache.kafka.common.network.Selector)
  </code></pre>
  <p>If I try to consume the same topic with authenticated and authorized (using the same Kafka ACL command as above) user everything work.</p>