1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fix up permissions evaluation

This commit is contained in:
Jeremy Stretch
2020-05-27 11:31:07 -04:00
parent a6a88a0d2e
commit fb7446487e
2 changed files with 6 additions and 19 deletions

View File

@@ -340,12 +340,11 @@ class ModelViewSet(_ModelViewSet):
permission_required = TokenPermissions.perms_map[request.method][0] % kwargs
# Enforce object-level permissions
if permission_required not in {*request.user._user_perm_cache, *request.user._group_perm_cache}:
attrs = ObjectPermission.objects.get_attr_constraints(request.user, permission_required)
if attrs:
# Update the view's QuerySet to filter only the permitted objects
self.queryset = self.queryset.filter(attrs)
return True
attrs = ObjectPermission.objects.get_attr_constraints(request.user, permission_required)
if attrs:
# Update the view's QuerySet to filter only the permitted objects
self.queryset = self.queryset.filter(attrs)
return True
def dispatch(self, request, *args, **kwargs):
logger = logging.getLogger('netbox.api.views.ModelViewSet')