-
-
Notifications
You must be signed in to change notification settings - Fork 84
[feature] Allowed read only access of shared objects to non-superusers #238 #444
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
base: master
Are you sure you want to change the base?
Conversation
0929c13 to
80511df
Compare
e72b20e to
c1da85c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't performed manual testing yet, I should be able to do this tomorrow.
In the meantime I have looked at the code and left some comments below.
I also noticed two more important points:
- Docs: the documentation has a section dedicated to shared objects, I think it's worth to update the text to reflect the functionality achieved in this PR.
- DRF 1.6: did you address this point which is listed in the issue description?
tests/testapp/tests/test_selenium.py
Outdated
| def test_organization_autocomplete_filter(self): | ||
| """ | ||
| The autocomplete_filter should show option to filter | ||
| shared objects to non-superuser. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I fully understand this docstring/comment: should the option to filter shared objects appear only to users who have the is_superuser flag set to False? Or what does this text mean exactly? Let's make it unambiguous.
| django-phonenumber-field~=8.1.0 | ||
| phonenumbers~=9.0.4 | ||
| openwisp-utils[rest,celery] @ https://github.com/openwisp/openwisp-utils/tarball/1.2 | ||
| openwisp-utils[rest,celery] @ https://github.com/openwisp/openwisp-utils/tarball/bump-drf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Revert this before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I found during testing in openwisp-controller:
openwisp/openwisp-controller#1024 (review)
We'll also need a way to protect some sensitive fields like credentials parameters, can you create a subissue for this and link it to the parent issue please? We should work on that as soon as this PR is ready.
docs/user/basic-concepts.rst
Outdated
| objects. However, they can use these shared objects when creating related | ||
| organization-specific resources. E.g., an organization manager can use a | ||
| shared VPN server to create a configuration template for their | ||
| organization. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's mention this works both in admin and REST API, let's mention that non superusers may be prevented to viewing sensitive details of certain shared objects which would allow them to gain unauthorized access to resources used by other organizations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Let's squash the commits into 1 so we can then add new commits on this branch for the follow up issues. Let's not merge this yet to avoid introducing potential security issues in the development version.
fd88b21 to
4c181e0
Compare
4c181e0 to
65c6b17
Compare
b1a8dc9 to
e81b36f
Compare
e81b36f to
f348ee4
Compare
openwisp_users/api/mixins.py
Outdated
| and not request.user.is_superuser | ||
| and "organization" in obj | ||
| and obj["organization"] is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIP: The organization field will be made configurable.
Checklist
Reference to Existing Issue
Closes #238
TODOS
-[x] DRF integration
-[x] Tests