如何使用acl限制对redis pubsub中某些主题的访问?

7kqas0il  于 2021-06-09  发布在  Redis
关注(0)|答案(1)|浏览(521)

我希望一些客户端无法订阅redis pubsub中的一些主题。redis acl可以这样吗?

4c8rllxm

4c8rllxm1#

是的,这就是如何使用acl将客户端限制为“foo”主题:

$ redis-cli
127.0.0.1:6379> ACL SETUSER limitedpubsub on nopass -@all +subscribe|foo
OK
127.0.0.1:6379> AUTH limitedpubsub ""
OK
127.0.0.1:6379> SUBSCRIBE bar
Reading messages... (press Ctrl-C to quit)
(error) NOPERM this user has no permissions to run the 'subscribe' command or its subcommand
^C
$ redis-cli
127.0.0.1:6379> AUTH limitedpubsub ""
OK
127.0.0.1:6379> SUBSCRIBE foo
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "foo"
3) (integer) 1

相关问题