-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Make BasePermission.has_object_permission return False #3783
Comments
Object permissions are only tested if the general permissions have already passed. From my POV it makes sense for them to default to |
Hi, I just bumped into this same issue and was baffled at first about what was happening. I too am using rest_condition, and was having a permission something like:
having the intuition to give permission if "the user is admin or the object creator or an object editor", but this is not what is happening, because IsAdminUser returns True (the default) for has_object_permission(). I now understand that the two paths of (general and object-level) permissions have to be examined separately when I design my permissions. I propose to either explicitly place a warning in the docs, that general permissions do not check at the object-level, or another solution might be to implement has_object_permission() return the same as has_permission() by default or otherwise in select cases, like IsAdminUser. I feel the source of the problem is that the general permission classes (like IsAdminUser) assume, that their own general permission check (has_permission) already passed (as the permission classes are in AND relation by default), so object-level permissions are automatically granted. Greets, |
Thinking a bit further, I think a workable solution for the rest_condition case would be to clearly separate the general-path and the object-level path. So a class something like this:
This would allow to clearly define a general permission check path with whatever conditions, and a separate object-level permission check path with different conditions.
with
I don't know if this makes sense, hope it helps someone in the future. |
For anyone finding this on google, this issue is continued at #7117 |
Hi
I'm using rest_condition app and have permissions like below:
And it always allows access at the object level because:
has_object_permission is not overridden in IsAdminUser, so it will always give True.
My idea here is to return False in BasePermission.has_object_permission(request, obj) and override this logic in IsAdminUser and IsAuthenticated permissons.
For now it happens that object level permissions a given by default.
I can create PR for this if you agree with the idea
The text was updated successfully, but these errors were encountered: