如何使用 acl 限制对 redis pubsub 中某些主题的访问? [英] How do I restrict access to certain topics in redis pubsub with acl?

查看:34
本文介绍了如何使用 acl 限制对 redis pubsub 中某些主题的访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want some clients to be unable to subscribe to some topics in Redis pubsub. Is this possible with redis acl?

推荐答案

是的,这就是您可以使用 ACL 将客户端限制为foo"主题的方法:

Yes, this is how you can use ACL to limit a client only to the "foo" topic:

$ 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

这篇关于如何使用 acl 限制对 redis pubsub 中某些主题的访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆