From c5662708e4bc64e633b06360586d10f3b5554280 Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Fri, 20 Nov 2026 20:17:04 -0300 Subject: [PATCH] docs(sharing): say that owner-only edits cover the shared object, not its contents The old wording ("sharing grants read access only") read as if a shared account's transactions were read-only, which keeps producing BOLA reports against intended behaviour. --- app/apps/api/permissions.py | 6 ++++-- app/apps/common/functions/permissions.py | 4 +++- app/apps/common/models.py | 8 +++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/apps/api/permissions.py b/app/apps/api/permissions.py index 1e84c504..648d1f19 100644 --- a/app/apps/api/permissions.py +++ b/app/apps/api/permissions.py @@ -18,8 +18,10 @@ class SharedObjectPermission(BasePermission): """Object-level ownership check for SharedObject-backed viewsets. The viewset's queryset includes other people's public and shared-with-them - objects. Sharing grants read access only, so writes are restricted to the - owner here, as the web UI does with ``get_shared_object_or_error``. + objects. Writes to the shared object itself are restricted to its owner + here, as the web UI does with ``get_shared_object_or_error``. Records inside + a shared or public account (transactions and the like) are not governed by + this check. Set ``shared_object_via`` on the viewset when the governing SharedObject is reached through a relation (e.g. ``"strategy"`` for a DCA entry). diff --git a/app/apps/common/functions/permissions.py b/app/apps/common/functions/permissions.py index 713c9f94..580ad441 100644 --- a/app/apps/common/functions/permissions.py +++ b/app/apps/common/functions/permissions.py @@ -20,7 +20,9 @@ def get_shared_object_or_error(klass, request, *, level=EDIT, via=None, **kwargs The object must be visible to the user. Denial raises :class:`Http404` so the response does not confirm that the id exists. ``EDIT`` - The object must be owned by the user. Denial raises + The object must be owned by the user. Use this for changes to the + shared object itself, not for records inside it (a shared account's + transactions are writable by everyone who can see it). Denial raises :class:`~django.core.exceptions.PermissionDenied` (HTTP 403), which the frontend surfaces as an "Access Denied" dialog. An object the user cannot even see raises :class:`Http404` instead, so 403 never confirms diff --git a/app/apps/common/models.py b/app/apps/common/models.py index f9a876fc..8fe58670 100644 --- a/app/apps/common/models.py +++ b/app/apps/common/models.py @@ -79,9 +79,11 @@ class SharedObject(models.Model): def is_editable_by(self, user): """Whether ``user`` may mutate this object. - Sharing grants read access only; mutation stays with the owner. Objects - with no owner remain editable by everyone, preserving the behaviour of - legacy/unowned objects. + Only the owner may edit, re-share or delete the object itself. This does + not cover what lives inside it: anyone who can see a shared or public + account may change its transactions, by design. Objects with no owner + remain editable by everyone, preserving the behaviour of legacy/unowned + objects. """ if self.owner is None: return True