sgroschupf/zkclient

org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth

Closed this issue · 1 comments

Issue:

  • I create a node(/mynode/1/2/3) using zkclient with ACL set to a particular user (Digest auth)
  • The method I used is zk.createPersistent(nodePath, true, aclList)
  • This creates the root node(/mynode) without any issue.
  • But child nodes are not created.

code:

String digest = "super:adminsecret";
ZkConnection connection = new ZkConnection("localhost:2181");
ZkClien zkClient = new ZkClient(connection, 5 * 60 * 1000, new BytesPushThroughSerializer());
zkClient.addAuthInfo("digest", digest.getBytes());      

Id userAuthId = new Id("digest", "super:adminsecret");
ArrayList<ACL> aclList = new ArrayList<ACL>(Collections.singletonList(new ACL(Perms.ALL, userAuthId)));
zkClient.createPersistent(path, true, aclList);
zkClient.writeData(path, data);

trace:

org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth for /mynode/1
	at org.I0Itec.zkclient.exception.ZkException.create(ZkException.java:68)
	at org.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:1001)
	at org.I0Itec.zkclient.ZkClient.create(ZkClient.java:528)
	at org.I0Itec.zkclient.ZkClient.createPersistent(ZkClient.java:294)
	at 
Caused by: org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth for /mynode/1
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:120)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1733)
	at org.I0Itec.zkclient.ZkConnection.create(ZkConnection.java:100)
	at org.I0Itec.zkclient.ZkClient$3.call(ZkClient.java:531)
	at org.I0Itec.zkclient.ZkClient$3.call(ZkClient.java:528)
	at org.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:991)
	... 7 more

FYI, /mynode is not accessible even from zkCli.sh using the CORRECT authentication

zkClient.addAuthInfo("digest", digest.getBytes());  

Id userAuthId = new Id("digest", "super:adminsecret");

Instead of this I tried,

zkClient.addAuthInfo("digest", digest.getBytes());  

Id userAuthId = new Id("auth", "")

This worked as expected.