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

标签 redis acl publish-subscribe access-control

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

最佳答案

是的,这就是如何使用 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

关于redis - 如何使用 acl 限制对 redis pubsub 中某些主题的访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60466697/

相关文章:

javascript - strophe.js PEP 处理程序未正确附加

azure - 在 Azure 上使用 Redis PubSub 作为通知引擎

php - Docker Redis 连接被拒绝

redis - 如何知道redis的master/slave状态?

ssl - ServiceFabric 独立 : Failed to get private key file

go - 这是基于消息总线的发布-订阅模式吗?

go - 如何连接到Redis(Sentinel)

hadoop - Hadoop纱:fair-scheduler.xml中的AclSubmitApps无效吗?

php - Cakephp 2 ACL ERR_TOO_MANY_REDIRECTS

javascript - 服务器上的 Meteor.publish 不会在客户端上显示新文档