Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic scattered on ACL request #38

Closed
marcelniessen opened this issue Jun 20, 2017 · 4 comments
Closed

Topic scattered on ACL request #38

marcelniessen opened this issue Jun 20, 2017 · 4 comments

Comments

@marcelniessen
Copy link

Hello,

I've run into an issue. The Plugin seems to mess up the topic name when sending it via a http request.

Here is my emq_auth_http.config:

auth.http.auth_req = https://localhost:3030/auth/mq
auth.http.auth_req.method = post
auth.http.auth_req.params = clientid=%c,username=%u,password=%P

auth.http.super_req = https://localhost:3030/auth/mq/su
auth.http.super_req.method = post
auth.http.super_req.params = clientid=%c,username=%u

auth.http.acl_req = https://localhost:3030/auth/mq/acl
auth.http.acl_req.method = post
auth.http.acl_req.params = access=%A,username=%u,clientid=%c,ipaddr=%a,topic=%t

These are the params the server receives:

{ access: '1',
  username: 'test',
  clientid: 'mqttjs_19ac257e',
  ipaddr: '172.17.0.1',
  topic: '%t##--------------------------------------------------------------------' }
POST /auth/mq/acl 200 1.283 ms - 2

I've used EMQ 2.1.2 and EMQ 2.2, both with the same result.

Or is topic of any special data type I have to parse in a different way?

Best Wishes
Marcel

@turtleDeng
Copy link
Member

@marcelniessen The topic that publish the message can not contain the wildcard of '+' '#'

@marcelniessen
Copy link
Author

marcelniessen commented Jun 21, 2017

@turtleDeng

I did not publish to any topics containing wildcards, I published and subscribed to test/1

Here is the server debug log:

08:48:05.770 [debug] Client(172.17.0.1:34352): RECV <<16,39,0,4,77,81,84,84,4,194,0,60,0,15,109,113,116,116,106,115,95,101,51,54,102,99,48,57,51,0,4,116,101,115,116,0,4,116,101,115,116>>
08:48:05.770 [info] Client(undefined@172.17.0.1:34352): RECV CONNECT(Q0, R0, D0, ClientId=mqttjs_e36fc093, ProtoName=MQTT, ProtoVsn=4, CleanSess=true, KeepAlive=60, Username=test, Password=******)
08:48:05.907 [info] Client(mqttjs_e36fc093@172.17.0.1:34352): SEND CONNACK(Q0, R0, D0, AckFlags=0, RetainCode=0)
08:48:05.908 [debug] Client(172.17.0.1:34352): SEND [<<" ">>,<<2>>,<<0,0>>,<<>>]
08:48:05.908 [debug] Client(172.17.0.1:34352): Keepalive at the interval of 75
08:48:05.908 [info] Session(mqttjs_e36fc093): Subscribe [{<<"$client/mqttjs_e36fc093">>,[{qos,1}]}]
08:48:05.925 [debug] Client(172.17.0.1:34352): RECV <<48,20,0,6,116,101,115,116,47,49,72,101,108,108,111,32,116,101,115,116,32,49,130,11,205,200,0,6,116,101,115,116,47,49,0>>
08:48:05.925 [info] Client(mqttjs_e36fc093@172.17.0.1:34352): RECV PUBLISH(Q0, R0, D0, Topic=test/1, PacketId=undefined, Payload=<<"Hello test 1">>)
08:48:05.938 [info] mqttjs_e36fc093/test PUBLISH to test/1: <<"Hello test 1">>
08:48:05.938 [info] Client(mqttjs_e36fc093@172.17.0.1:34352): RECV SUBSCRIBE(Q1, R0, D0, PacketId=52680, TopicTable=[{<<"test/1">>,0}])
08:48:05.949 [info] Session(mqttjs_e36fc093): Subscribe [{<<"test/1">>,[{qos,0}]}]
08:48:05.949 [info] Client(mqttjs_e36fc093@172.17.0.1:34352): SEND SUBACK(Q0, R0, D0, PacketId=52680, QosTable=[0])
08:48:05.949 [debug] Client(172.17.0.1:34352): SEND [<<144>>,<<3>>,<<"��">>,<<0>>]

I can publish or subscribe to any topic name. EMQ receives the correct topic name as you can see in the log, but the topic param of the http auth request is always the same scattered one.
%t##--------------------------------------------------------------------

@marcelniessen
Copy link
Author

@turtleDeng Did you see that I didn't use any wildcards? How does it come that the topic of the http request is always the same scattered one regardless of the topic used?

@a3aanwisse
Copy link

a3aanwisse commented Dec 20, 2017

I also ran into this issue. Actually if I change
auth.http.acl_req.params = access=%A,username=%u,clientid=%c,ipaddr=%a,topic=%t
into
auth.http.acl_req.params = access=%A,username=%u,clientid=%c,topic=%t,ipaddr=%a
the IP address comes in strange.

See the following data from wireshark:
GET /mqtt/acl?accessType=1&username=testuser1&clientId=33880f61-daba-4910-9238-e9d00bed6ea41513782718549&ipAddress=127.0.0.1&topic=%25t%23%23--------------------------------------------------------------------
and with changed parameters:
GET /mqtt/acl?accessType=1&username=testuser1&topic=test/topic&clientId=33880f61-daba-4910-9238-e9d00bed6ea41513782718549&ipAddress=%25a%23%23--------------------------------------------------------------------

Using wildcards also works:
GET /mqtt/acl?accessType=1&username=testuser1&topic=test%2F%2B%2F%23&clientId=33880f61-daba-4910-9238-e9d00bed6ea41513784431165&ipAddress=%25a%23%23--------------------------------------------------------------------

Created isse #57 for this with a temporary solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants