Fix leak: redact per-person on authed non-member reads
A logged-in NON-member of a public/unlisted tree could read living people's dates, real alternate names, and media (incl. downloading photos) through the family-view endpoints — only the person LIST was redacted; list_events, list_relationships, list_names, list_media gated on can_view_tree alone. For non-members, these now delegate to the same visibility-filtered reads the public surface uses (person_visibility-driven): living-person events/names dropped, relationships touching a hidden person dropped, media limited to full-visibility persons, and media download (get_media → media_content) 404s for a redacted/unlinked person's media. Members are unchanged. Adds list_public_relationships_for_person / list_public_media / can_view_media to public_view_service. Test: an authed non-member sees no living-person PII across events/names/relationships/media and can't download a living person's file, while the owner still sees everything. Full suite: 72 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Justin Paul <justin@jpaul.me>
This commit is contained in:
@@ -97,6 +97,13 @@ async def list_events(
|
||||
"""All events in the tree — lets the family view compute birth/death years."""
|
||||
if not await privacy.can_view_tree(session, user_id=viewer_id, tree=tree):
|
||||
raise Forbidden("not permitted to view this tree")
|
||||
# Non-members get the redacted projection (no living-person dates).
|
||||
if await privacy.get_membership_role(session, viewer_id, tree.id) is None:
|
||||
from app.services import public_view_service
|
||||
|
||||
return await public_view_service.list_public_events(
|
||||
session, viewer_id=viewer_id, tree=tree
|
||||
)
|
||||
stmt = (
|
||||
select(Event)
|
||||
.where(Event.tree_id == tree.id, Event.deleted_at.is_(None))
|
||||
@@ -110,6 +117,13 @@ async def list_events_for_person(
|
||||
) -> list[Event]:
|
||||
if not await privacy.can_view_tree(session, user_id=viewer_id, tree=tree):
|
||||
raise Forbidden("not permitted to view this tree")
|
||||
# Non-members only see a full-visibility person's events (redacted → none).
|
||||
if await privacy.get_membership_role(session, viewer_id, tree.id) is None:
|
||||
from app.services import public_view_service
|
||||
|
||||
return await public_view_service.list_public_person_events(
|
||||
session, viewer_id=viewer_id, tree=tree, person_id=person_id
|
||||
)
|
||||
stmt = (
|
||||
select(Event)
|
||||
.where(
|
||||
|
||||
Reference in New Issue
Block a user