Erlaube berechtigten Konten, verknüpfte Originale über die Zugänge des Owners zu lesen.
Deploy Development / deploy (push) Successful in 26s
Test Suite / pytest-backend (push) Successful in 1m51s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 9s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-18 21:47:30 +02:00
1 parent 562c0848b1
commit 75a3949f7c
14 files changed
+815 -93

No files matched your search

+25 -7
View File
@@ -701,7 +701,18 @@ def _actor_rights_for(conn, actor: UUID, kind: str, resource_id: UUID, context:
return rights
def grant_access(conn, actor: UUID, kind: str, resource_id: UUID, grantee_id: UUID, can_read: bool, can_edit: bool, can_share: bool, context: Ctx | None) -> dict:
def grant_access(
conn,
actor: UUID,
kind: str,
resource_id: UUID,
grantee_id: UUID,
can_read: bool,
can_edit: bool,
can_share: bool,
context: Ctx | None,
use_owner_sources: bool = False,
) -> dict:
if grantee_id == actor:
raise unprocessable("Die eigene Berechtigung wird nicht als Freigabe gespeichert.")
if not can_read:
@@ -731,33 +742,40 @@ def grant_access(conn, actor: UUID, kind: str, resource_id: UUID, grantee_id: UU
raise not_found()
existing = conn.execute(
"""
SELECT id FROM access_grants
SELECT id, use_owner_sources FROM access_grants
WHERE NOT is_exception AND grantee_subject_id = %s
AND resource_kind = %s AND resource_id = %s AND context_kind IS NULL
""",
(grantee_id, kind, resource_id),
).fetchone()
if owner:
source_access = bool(use_owner_sources)
elif existing is None:
source_access = False
else:
source_access = bool(existing["use_owner_sources"])
if existing is None:
row = conn.execute(
"""
INSERT INTO access_grants (
grantee_subject_id, resource_kind, resource_id,
can_read, can_edit, can_share, can_delete, is_exception, created_by
can_read, can_edit, can_share, can_delete, is_exception, created_by,
use_owner_sources
)
VALUES (%s, %s, %s, %s, %s, %s, false, false, %s)
VALUES (%s, %s, %s, %s, %s, %s, false, false, %s, %s)
RETURNING *
""",
(grantee_id, kind, resource_id, can_read, can_edit, can_share, actor),
(grantee_id, kind, resource_id, can_read, can_edit, can_share, actor, source_access),
).fetchone()
else:
row = conn.execute(
"""
UPDATE access_grants
SET can_read = %s, can_edit = %s, can_share = %s
SET can_read = %s, can_edit = %s, can_share = %s, use_owner_sources = %s
WHERE id = %s
RETURNING *
""",
(can_read, can_edit, can_share, existing["id"]),
(can_read, can_edit, can_share, source_access, existing["id"]),
).fetchone()
audit(conn, actor, resource["home_scope_id"], "grant_created", kind, resource_id, context)
return row