samuel / go-zookeeper

Native ZooKeeper client for Go. This project is no longer maintained. Please use https://github.com/go-zookeeper/zk instead.
BSD 3-Clause "New" or "Revised" License
1.64k stars 672 forks source link

Conn AddAuth not working? #231

Closed likevin97 closed 4 years ago

likevin97 commented 4 years ago

I'm trying to authenticate using the digest ACL scheme, but AddAuth doesn't seem to be triggering any logs in the client or the server. Here is the relevant code snippet:

client, _, err := zk.Connect(hosts, time.Second, loggerOption)
err = client.AddAuth("digest", []byte("user:dummy"))
if err != nil {
    return nil, fmt.Errorf("Failed to authenticate against zookeeper with %s", err)
}

There doesn't seem to be an error or any log at all for AddAuth. Not sure if AddAuth is doing anything functionally.

likevin97 commented 4 years ago

Also willing to consider other methods of authentication if this approach doesn't work.

likevin97 commented 4 years ago

I realize that AddAuth isn't properly adding the authCreds to the Conn. I tried adding the auth creds before even going into the loop() in Connect() using a separate thread but it seems like it still didn't get added.

likevin97 commented 4 years ago

Found the issue. It turns out that setting the ACLs for the zookeeper nodes was required for it to properly authenticate.