-
Notifications
You must be signed in to change notification settings - Fork 178
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
Issue with ACL on MySQL #18
Comments
Subscribing to test/1/test should work, but test/2/test not, as write privileges don't grant read. |
Edit: Note: I think you confused test/1/test and test/2/test, test/1/test has rw set to 2 and test/2/test set it to 1 ;) Ok, that is good to know. Was not 100% clear to me from the Documentation but then Sub is 1, Pub is 2 and PubSub is 3, that's fine. However, I can only subscribe to the topic where PubSub (3) is set. Also for test/2/test I get a rejection. My Log looks like this (Subscribing to 1,2 and 3 after another. Only connecting to test/3/test is successful though the log doesn't show it) 1557152527: New connection from 212.101.61.123 on port 1883. When I start mosquitto manually from the command line and see the stdout I can provide this log: --- Subscribing to /test/1/test Logging settings I have set in the config file: Do I need to set anything else to get more logging? When I run the query manually: `MariaDB [mosquitto]> SELECT topic FROM acl INNER JOIN account ON account.id=acl.user WHERE (username = "test") AND (rw = 1 OR rw=3); +-------------+ | topic | +-------------+ | test/2/test | | test/3/test | +-------------+ 2 rows in set (0.00 sec) |
That's odd. Could you try adding some debug printing to the CheckAcl method at backends/mysql.go? Maybe printing |
Thanks for your quick replies. I have added for debugging in backends/mysql.go function CheckAcl the following lines:
Right at the start of the function and added 2 debugs for aclTopic:
Output when subscribing to test/3/test (Permission set to 3, rw): DEBU[2019-05-07T09:23:16+02:00] checking acl cache for test Output when subscribing to test/1/test (Permission set to 2, w): Output when subscribing to test/2/test (Permission set to 1, r): I didn't see any GO code before in my life but mixing the programming languages I do know I think that And for each topic it keeps telling me Unfortunately I don't know how to print the actual executed query. I'm a bit curious though why the "acc" variable is set to "4". Where does that come from? If I understand the o.DB.Select statement correctly that should be the requested access level (1 for read, 2 for write), right? How comes that is 4 in my case? Best Regards, |
Ok, as I suspected, you're indeed getting subscribe requests, which appeared in Mosquitto 1.5 and are also part of 1.6 as defined here (from the latest You can read how it differs from So all you need to do is to account for subscriptions (i.e., |
Allright, thanks a lot for your support :) |
Btw, during testing further with loraserver when wondering why the server didn't get any messages I found out you need to set rw=4 so it can subscribe and rw=1 so it actually receives messages, otherwise it subscribes but doesn't get any messages |
Sorry for re-asking the question, but I am still confused about what is difference between read permission and subscribe permission. Can you help me to understand the difference? Thank you very much!!! |
From the header:
The main difference is that Does that clear it? |
Thank you iegomez. But how to write the acl rules in the backend like mysql or postgresql if I need to do something like this
Thank you~ |
These are the values for the
So if you want to treat |
So i have to explicitly set acl rules with each topic by assigning proper acc value and add a acl rule which disables the wildcard subscription. Is that correct? |
If you want to. You don't need to treat |
Oh I understand what you stated. |
Hi! |
Hi @IsabelManiega. Setting Also, this issue is unrelated. |
The problem is that: If I select: "superuser" = False, (a normal user), but.. AND, If I select "superuser=True", the user will be able to Read and Write Therefore, How I perform this "Read" option? (for a user able to Read but never able to write) Thank you very much for your attention ;) |
@IsabelManiega I believe you're missing exactly what's discussed in this issue: allowing for subscribe. If your client is sending |
Thanks!!! It is working, the user is able to ONLY READ. Thank you very much !!! ;-) |
I have set up mosquitto-go-auth with mosquitto 1.6.0 and user checks are successful, however I have issues with the ACL checks. I took my knowledge from the Postgres part of the documentation and just transfered it to MySQL Queries:
(See https://github.com/iegomez/mosquitto-go-auth#postgresql )
Now I have a Table with 3 different Topics:
`MariaDB [mosquitto]> select * from acl;
+----+------+-------------+----+
| id | user | topic | rw |
+----+------+-------------+----+
| 1 | 2 | test/1/test | 2 |
| 2 | 2 | test/2/test | 1 |
| 3 | 2 | test/3/test | 3 |
+----+------+-------------+----+
3 rows in set (0.00 sec)
`
Now if I want to publish to topic "test/2/test", I get ACL deny which is correct.
If I want to publish to the other 2 topics, I get ACL allow which is also correct.
If I want to publish to any topic that is not existent, I get ACL deny which is what I expected.
Now my Issue is with subscribing.
If I want to subscribe to "test/3/test" I get ACL allow which is fine.
If I want to subscribe to the other 2 Topics I get ACL deny which is not what I expected.
My Query looks like this:
SELECT topic FROM acl INNER JOIN account ON account.id=acl.user WHERE (username = ?) AND (rw = ? OR rw=3)
Usually this should allow a user to subscribe to topics where the Query return 1 or 3 and publish to a topic where the Query returns 2 or 3. The second seems to work but for subscribe there seems to be some issue I don't understand.
In a different issue I read about MOSQ_ACL_SUBSCRIBE but don't see how that would be related?
Best Regards,
Nils
The text was updated successfully, but these errors were encountered: