moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 513 forks source link

Problem while trying to authorize a user for subscribing on multiple topics #712

Open erwrow opened 6 years ago

erwrow commented 6 years ago

As the title suggest, i'm having troubles with that, im using the following command:

mosca adduser test test --credentials ./credentials.json --authorize-publish 'topic/' --authorize-subscribe 'topic/', 'another_topic/*'

this generate the following text on the file "credentials.json"

{ "test": { "salt": "jLJ4fa+EK8of0RXbXTyEO65mf26TBjtp/s2axxAw3rSaQihpkrpH0VZ/Cv8BplRejs/CXGhQkkVNk9jfR7jp+g==", "hash": "HL5QOH8ugd3syRmcIG1PbmdogcYlHSb++6JtDd8s1+YRGzLmp3+6K5XoSgKLTXFaPtl2NdI0JuiFNLDPYXerP6HEXScu3BxnC1q1WRTKkDxyVY5IDKoz/MV7CuBy/6b28hJePaLF+9sNr3FoEtwzLtR/xOC8jbXBDyanyw/JSiw=", "authorizePublish": "topic/", "authorizeSubscribe": "topic/, another_topic/*" } }

(hash may vary since i'm not really using that username and password nor topics)

and when i execute: mosca -v --credentials ./credentials.json and try to connect it says:

subscribe not authorized (topic=topic/keepalive, client=test) subscribe not authorized (topic=another_topic/sub_topic, client=test)

but if i only authorize and use one topic everything works fine, i'm thinking that "topic/, another_topic/" is not the correct sentence, and i'm doing something wrong when i try to authorize multiple topics, any ideas? or this cannot be done with this broker?

mcollina commented 6 years ago

You can also edit the credentials file by hand. Or send a PR to fix the bug on the adduser command.

erwrow commented 6 years ago

And what would the syntax be?

mcollina commented 6 years ago

The patterns are specified with https://www.npmjs.com/package/glob.