jpmens / mosquitto-auth-plug

Authentication plugin for Mosquitto with multiple back-ends (MySQL, Redis, CDB, SQLite3)
Other
825 stars 496 forks source link

Mosquitto ACL, Redis backend not working with topic having space #309

Closed sachingupta141 closed 5 years ago

sachingupta141 commented 7 years ago

I am working on Mosquitto, and using Redis as the back end to handle both username/password pair authentication and ACL. I am using JPmens' authentication plugin to do this.

the mosquitto conf:

auth_opt_backends redis
auth_plugin /etc/mosquitto/auth-plug.so
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

Everything is working fine. But when I start using topic with spaces, it simply denied me from publish/subscribe.

I have already set this topic value in Redis:

SET "user1-sample topic" 2

Mosquitto logs:

Denied PUBLISH from sample_publisher (d0, q2, r0, m1, 'sample topic', ... (10 bytes))

Is there anything, I can do to make this work, like acl query change or change in redis-data.

jpmens commented 6 years ago

What is probably happening is that the query you configure (GET %s) gets spaces interpolated into it in such a way as that the hiredis library and the sprintf(3) we use to format that gets muddled up.

The only short-term fix I can think of is to configure GET '%s', but I don't know whether that will work. Can you try that please?