🐛(backend) fix dysfunctional permissions on document create
When creating a document access, users were benefitting on the targeted document from the highest access right they have among all documents. This is because we forgot to filter on the document ID when retrieving the role of the user. We improved all tests to secure this issue.
This commit is contained in:
committed by
Samuel Paccoud
parent
bbcb5e0cf1
commit
1fc3029d12
@@ -69,6 +69,7 @@ class BaseAccessSerializer(serializers.ModelSerializer):
|
||||
if not self.Meta.model.objects.filter( # pylint: disable=no-member
|
||||
Q(user=user) | Q(team__in=user.teams),
|
||||
role__in=[models.RoleChoices.OWNER, models.RoleChoices.ADMIN],
|
||||
**{self.Meta.resource_field_name: resource_id}, # pylint: disable=no-member
|
||||
).exists():
|
||||
raise exceptions.PermissionDenied(
|
||||
"You are not allowed to manage accesses for this resource."
|
||||
|
||||
Reference in New Issue
Block a user