moscajs / mosca

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

Can't use + in publish #486

Closed benu2016 closed 8 years ago

benu2016 commented 8 years ago

Hello, I have this in credentials.json:

"testUser": {
    "salt": ...,
    "hash": ...,
    "authorizePublish": "users/+/chats/testUser",
    "authorizeSubscribe": "users/testUser/chats/#"
  }

And now I want to publish a Message to: "users/secondUser/chats/testUser" but it doesn't work.

Server gives me "published:clientId2 $SYS/Hk9g9sEN/disconnect/clients" But if I change this line: "authorizePublish": "users/+/chats/testUser" to"authorizePublish": "users/secondUser/chats/testUser" then it works.

Is this a Bug ?

mcollina commented 8 years ago

the checks are based on minimatch (for historical reasons). You should use a * or a **.

You can send a PR if you want to rewrite those on top of Qlobber.

benu2016 commented 8 years ago

I tried this: /users/*/chats/testUser*/** for /users/secondUser/chats/testUser and /users/secondUser/chats/testUser/request, but both don't work

mcollina commented 8 years ago

try /users/*/chats/testUser

benu2016 commented 8 years ago

If I try /users/*/chats/testUser then it works only for /users/secondUser/chats/testUser.

But I want it to work for one additional topic level more, like: /users/secondUser/chats/testUser/request

But the Problem is /request. How can I solve that? The minimatch */** doesn't work

benu2016 commented 8 years ago

I meant /, not */**

mcollina commented 8 years ago

try matching that just using minimatch, or send a PR to use Qlobber instead of minimatch :).