-
Notifications
You must be signed in to change notification settings - Fork 567
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
get_objects_for_user
behavior change
#325
Comments
I have the same issue with It comes from the option I don't really understand if it comes from a misunderstanding of global permissions from my side, or from a shifting of paradigm from Guardian. Either way, I don't think we will be the only ones with this issue. |
+1 |
If
This is how I interpreted the global permission vs object based permission handling in guardian. The flag |
Your scenarios are right, although it gets a little bit more complicated when group permissions are involved. My experience with Django permissions is that you use either global or per-object permissions. However, it can be useful to add global permissions to a group, in order to say "any user in this group should have that permission for every object related to this group". That way you can update the permissions automatically. The test case provided by @xordoquy is failing because a group is created with all global permissions (https://github.com/tomchristie/django-rest-framework/blob/master/tests/test_permissions.py#L274-L287). This is another example of a usage were there is a clear distinction between global and per-object permissions. I think that |
Addressing this downstream in encode/django-rest-framework#3165 I think the new behavior probably makes sense - I believe when I originally came to integrating a guardian filter with REST framework that was what I was first expecting. However either could be reasonable. Certainly it's subtle so worth documenting well.
I guess that would be my preference too, given that it appears to be a behavioral change, but equally it's kinda too late now that 1.3 is released, so {shrug}. WRT integration with REST framework - sticking with the existing behavior so as not to mess with folks upgrading existing deployments. |
👍 I also think changing the behavior is counterintuitive at best. Got bit by the same issue when upgrading to 1.3 to get Django 1.8 compatibility. |
So if I understand this correctly, this is a documentation issue, correct? i.e. we should keep the current behavior and document it? How do we move forward on this? |
It's been a while since this was closed, but I still missed this, and took a while to figure out I needed |
IMHO probably too late to change the defaults now. Having said said, any pull requests to address this issue (e.g. in documentation or examples) appreciated. |
I tried running Django REST Framework test suite against the django-guardian 1.3 and we have a failing test case that was passing with 1.2.5
https://travis-ci.org/tomchristie/django-rest-framework/jobs/65945259
which corresponds to this test: https://github.com/tomchristie/django-rest-framework/blob/master/tests/test_permissions.py#L373
By investigating a bit, it seems the get_objects_for_user has changed.
For this test in 1.2.5 it returned an empty list, while it's now - 1.3 - a non empty list
The text was updated successfully, but these errors were encountered: