Skip to content

Allow project collaborators to be added by user ID - #523

Open
dnass wants to merge 3 commits into
masterfrom
add-collaborator-by-id
Open

dnass wants to merge 3 commits into
masterfrom
add-collaborator-by-id

Conversation

@dnass

@dnass dnass commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

More preparation for MuckRock/documentcloud-frontend#1219. When inviting a project collaborator, the /projects/<id>/users/ endpoint now accepts a DocumentCloud user ID (or an email address as before).

@mitchelljkotler mitchelljkotler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude pointed out one security issue:

documentcloud/projects/serializers.py:194: The new writable user field uses queryset=User.objects.all(), so anyone who can manage a project can add any user ID on the platform. This bypasses User.objects.get_viewable. Before this change you had to know the user's email.
Failure scenario: An attacker creates a project and POSTs {"user": N} for N=1,2,3,… A 201 shows the user exists. Each added user then shares a project with the attacker, so get_viewable and GET /api/projects//users/?expand=user reveal their name, username, uuid, avatar and organizations. The attacker can list the whole user base and push unwanted project memberships onto arbitrary users.

Should we require the user already be visible to the project owner before they can add someone?

@dnass

dnass commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Should we require the user already be visible to the project owner before they can add someone?

That makes sense and I just pushed the change.

There may also be a need to align user visibility conditions across Squarelet and DocumentCloud. The Squarelet user search API returns all non-private users, so this restriction introduces some new cases where you can see a user in search but not add them to your project. The reverse is also true — DocumentCloud doesn't seem to respect (or even store) users' private status from Squarelet, so there will also be cases where a user is eligible to be added to a project but doesn't appear in the collaborator search results. Should Squarelet's visibility rules eventually become the source of truth for other products too?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants