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

mosquitto disconnect the client when subscribe is not authorized #1016

Closed
ibrahimkoujar opened this Issue Nov 5, 2018 · 7 comments

Comments

Projects
None yet
4 participants
@ibrahimkoujar

ibrahimkoujar commented Nov 5, 2018

Hello

The problem is when user try to connect to the broker its work normally but when he try to subscribe to unauthorized topic the package disconnecting the user socket from broker, its happened only with subscribe, publish works fine.

123

Backend log
1234

mqtt client app

`
var mqtt = require('mqtt');

var mqttClient = mqtt.connect('mqtt://localhost:1883', {
username: "device_1",
password: "secret",
});

mqttClient.on('connect', function () {
mqttClient.subscribe("topic2");
console.log("App connected to MQTT Broker!");
});
`

p.s: same result in auth-plug and go-auth packages.

Thanks.

@ralight

This comment has been minimized.

Contributor

ralight commented Nov 5, 2018

Could you provide some more details on the configuration you're using please?

@ibrahimkoujar

This comment has been minimized.

ibrahimkoujar commented Nov 6, 2018

@ralight Thanks for your response.

Its default configuration nothing changed in mosquitto.conf file I have just added auth data

auth_plugin /home/ubuntu/mosquitto/go-auth.so
auth_opt_backends http
auth_opt_http_host 127.0.0.1
auth_opt_http_port 3000
auth_opt_http_getuser_uri /auth/mqtt/check
auth_opt_http_superuser_uri /auth/mqtt/superuser
auth_opt_http_aclcheck_uri /auth/mqtt/acl

auth package owner said its from mosquitto.

@karlp

This comment has been minimized.

Contributor

karlp commented Nov 6, 2018

auth packager said it's from mosquitto what? There's no go-auth.so package provided here at least. Are you sure the plugin is not crashing on something unexpected and that's causing it to drop things?

@ibrahimkoujar

This comment has been minimized.

ibrahimkoujar commented Nov 6, 2018

@karlp
I tried these two packages:

https://github.com/jpmens/mosquitto-auth-plug
https://github.com/iegomez/mosquitto-go-auth

mosquitto-go-auth issue:
iegomez/mosquitto-go-auth#10 (comment)

same result client disconnect when he try to subscribe to unauthorized topic.
if the topic is authorized it's works fine.

@Daedaluz

This comment has been minimized.

Contributor

Daedaluz commented Nov 6, 2018

Testing with my own golang plugin: returning false from mosquitto_auth_acl_check when access flag is MOSQ_ACL_SUBSCRIBE will indeed result in "Socket error on client", but not when it's MOSQ_ACL_READ.
Running a minimal plugin in c display the same behavior.
https://github.com/Daedaluz/mosquitto_plugin_template_c
mosquitto_sub continues to reconnect when using the plugin.

Just tried with tag v1.5.3

@ralight ralight added this to the 1.5.4 milestone Nov 7, 2018

ralight added a commit that referenced this issue Nov 7, 2018

@ralight

This comment has been minimized.

Contributor

ralight commented Nov 7, 2018

Thanks for the description @ibrahimkoujar and for confirming @Daedaluz. This should now be fixed in the fixes branch, could you check and close the issue if it's working for you?

@ibrahimkoujar

This comment has been minimized.

ibrahimkoujar commented Nov 7, 2018

Thanks for you @ralight @Daedaluz , problem has been resolved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment