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

mosquitto disconnect the client when subscribe is not authorized #1016

Closed
ibrahimkoujar opened this issue Nov 5, 2018 · 7 comments
Closed
Labels
Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Milestone

Comments

@ibrahimkoujar
Copy link

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:https://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
Copy link
Contributor

ralight commented Nov 5, 2018

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

@ibrahimkoujar
Copy link
Author

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
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
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?

@ralight ralight added the Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. label Nov 7, 2018
@ibrahimkoujar
Copy link
Author

ibrahimkoujar commented Nov 7, 2018

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

@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Projects
None yet
Development

No branches or pull requests

4 participants