【问题标题】:How to use Redis as back end for mosquitto ACL (JPmens plugin is used)?如何使用 Redis 作为 mosquitto ACL 的后端(使用 JPmens 插件)?
【发布时间】:2015-05-08 00:23:09
【问题描述】:

我正在开发 Mosquitto,并计划使用 Redis 作为后端来处理用户名/密码对身份验证和 ACL。我正在使用JPmens' authentication plugin 来执行此操作。身份验证运行良好,但我无法使 ACL 正常工作。 Redis 使用唯一密钥,并且用户名(在我的情况下为密钥)用于用户名/密码对以进行身份​​验证。我尝试在集合/列表中混合用户名、密码和主题,但它们都不起作用。

蚊子会议:

auth_plugin /etc/mosquitto/auth-plug.so
auth_opt_backends redis
auth_opt_redis_host 127.0.0.1
auth_opt_redis_port 6379
auth_opt_redis_userquery GET %s
auth_opt_redis_aclquery GET %s-%s

以下名称/密码对可以正常进行身份验证

SET user1 PBKDF2$sha256$901$Qh18ysY4wstXoHhk$g8d2aDzbz3rYztvJiO3dsV698jzECxSg

SET user2 PBKDF2$sha256$901$R74X2ae3MufMS20M$CAbXZFDmXJN7Cc28Dm/Z97OfM8Tz1JHn ...

以下设置不适用于 ACL:(a/b... 作为主题)

sadd user22 PBKDF2$sha256$901$Qh18ysY4wstXoHhk$g8d2aDzbz3rYztvJiO3dsV698jzECxSg a/b c/d

rpush user33 PBKDF2$sha256$901$q5/N74O6Iaf/e8Cg$dEA3tZSi/sJeXKAkX39Gd3agy2WY96gE e/f

这样做的正确方法是什么? 在 Redis API 中,aclrequery 表明:

Single stepping until exit from function be_redis_aclcheck, which has no line number information.

redisCommand (c=0x6537d0, format=0x6561c0 "GET user1-t/c") at hiredis.c:1345
1345    void *redisCommand(redisContext *c, const char *format, ...) {
(gdb) bt
0  redisCommand (c=0x6537d0, format=0x6561c0 "GET my-t/c") at hiredis.c:1345
1  0x00007ffff5e61376 in be_redis_aclcheck () from /etc/mosquitto/auth-plug.so
2  0x00007ffff5e5c351 in mosquitto_auth_acl_check ()

来自 /etc/mosquitto/auth-plug.so

这里,user1 是用户名,t/c 是主题。 GET user1-t/c 似乎告诉我在 Redis 数据库中需要一个字符串类型。谁能给我一个如何让它工作的例子?

谢谢

【问题讨论】:

    标签: authentication redis acl mqtt mosquitto


    【解决方案1】:

    我已经弄清楚它是如何工作的。如果 MQTT 代理只允许客户端 user1 发布和订阅“a/b”和“c/d”主题,则 Redis 中 JPmens 插件的正确 ACL 数据将是:

    user1-a/b 2

    user1-c/d 2

    “user1-a/c”是键,2是值。

    【讨论】:

      【解决方案2】:

      这不是首选,如果 Redis 由于任何原因出现故障,您的整个系统也会出现故障。

      这将是您架构中的 SPF(单点故障)。

      【讨论】:

        猜你喜欢
        • 2012-05-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-06-04
        相关资源
        最近更新 更多