-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
I've defined a fairly standard set of permissions, and am using rest_condition to generate a set of conditional permissions.
I'm also trying to use these w/ the IsAuthenticated permission class, but have omitted it here for brevity.
In a simple ViewSet that uses the rest_condition permission class defined below, it appears as though the only permission that is being run in many circumstances is the IsSuperuser class.
I've found that by reordering things, I can get the others to run, but I feel as though this is unintended behaviour. Is it because one of the permission classes is an object-specific permission, while the others aren't?
class IsListView(permissions.BasePermission):
def has_permission(self, request, view):
return bool(view.action == 'list')
class IsSuperuser(permissions.BasePermission):
def has_permission(self, request, view):
return request.user.is_superuser
class IsFilteringOwnResources(permissions.BasePermission):
def has_permission(self, request, view):
return bool(request.QUERY_PARAMS.get('user') == str(request.user.id))
class IsResourceOwner(permissions.BasePermission):
def has_object_permission(self, request, view, obj):
return bool(obj.user == request.user)
IsSuperuserOrResourceOwner = Or(Or(IsSuperuser, IsResourceOwner), And(IsListView, IsFilteringOwnResources))
In my tests, I have added debugging statements in each permission class.
Metadata
Metadata
Assignees
Labels
No labels