fix: hide reference details from users who cannot see them#1256
Conversation
getReference applied no visibility filter, so any signed-in user could read any reference's full detail — members, groups, and settings — by guessing its id. It now enforces the same visibility rule as the reference list: a non-member, non-administrator caller gets a 404, indistinguishable from a missing reference.
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider moving the visibility check into
getReferenceImpl(or a shared lower-level helper) so that all single-reference reads consistently enforce visibility without relying on each server handler to remember to callcheckReferenceVisibility. - Since
checkReferenceVisibilityalready encapsulates thereferenceVisibilityFilterand existence check, it may be worth documenting or enforcing that other code paths callinggetReferenceImplalso use this helper to avoid subtle discrepancies in visibility behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider moving the visibility check into `getReferenceImpl` (or a shared lower-level helper) so that all single-reference reads consistently enforce visibility without relying on each server handler to remember to call `checkReferenceVisibility`.
- Since `checkReferenceVisibility` already encapsulates the `referenceVisibilityFilter` and existence check, it may be worth documenting or enforcing that other code paths calling `getReferenceImpl` also use this helper to avoid subtle discrepancies in visibility behavior.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Re: moving the visibility check into the data-layer
The |
Summary
checkReferenceVisibilitytoreferences/data.ts, treating a hidden reference and a missing one identically to avoid leaking existence.