digest加密
对用户名:密码(test:test)进行加密签名,得到结果V28q/NynI4JI3Rk54h0r8O5kMug=
echo -n test:test | openssl dgst -binary -sha1 | openssl base64
V28q/NynI4JI3Rk54h0r8O5kMug=
创建带权限的节点
创建的节点名字为/test,data内容是data222,用户名密码分别是test:test,权限是rwadc
[zk: 10.96.88.222:2181(CONNECTED) 5] create /test data222 digest:test:V28q/NynI4JI3Rk54h0r8O5kMug=:rwadc
Created /test
[zk: 10.96.88.222:2181(CONNECTED) 6] ls /
[lean, taobao-pamirs-schedule, dpm, test, token, zookeeper, config]
可以发现直接查看节点内容是不行的
[zk: 10.96.88.222:2181(CONNECTED) 7] get /test
Authentication is not valid : /test
[zk: 10.96.88.222:2181(CONNECTED) 8] rmr /test
Authentication is not valid : /test
如何访问带权限的节点呢
首先进行赋权
[zk: 10.96.88.222:2181(CONNECTED) 9] addauth digest test:test
再查看或者删除都是可以的哟
[zk: 10.96.88.222:2181(CONNECTED) 10] get /test
data222
cZxid = 0x200728d74
ctime = Wed Aug 08 18:41:16 CST 2018
mZxid = 0x200728d74
mtime = Wed Aug 08 18:41:16 CST 2018
pZxid = 0x200728d74
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 0