Description
This is a vector for abuse. We should require confirmation from the person being added before adding them, just like Github does for adding someone as an owner to a repo/team.
Implementation steps added by carols10cents:
The following tasks assume we'll need a web UI for this in order to support users with arbitrarily old versions of cargo. I don't think crates.io can have a state where this feature is "half on", and even if we did, I think we'd have to stay in that state forever because people are always going to be using older versions of cargo. I'm open to hearing ideas on this issue though!
Crates.io Deployable chunk 1: Listing invitations
- (Backend of deployable chunk 1 of owner invitations #1040) Add a new table, crate_owner_invitations or something, that has columns:
- id of the user who ran
cargo owner --add
- id of the user who is being added
- id of the crate involved
status of the invitiationthe only invitations in this table should be pending invitations; accepted invitations can be removed from this table and records added to crate_owners instead; declined invitations can be removed from this table.- when this request was created
- id of the user who ran
- Don't add records to this table on a
cargo owner --add
in this PR, add records to this table either manually withpsql
or in tests - (Backend of deployable chunk 1 of owner invitations #1040) Make an API route that can list all of the currently logged in user's pending invitations
- (Frontend page for listing pending owner invites #1057) Make a frontend page that calls that API route and displays the currently logged in user's pending invitations (don't link to this page from anywhere yet though)
Crates.io Deployable chunk 2: Accepting invitations
Still not creating records in crate_owner_invitations when cargo owner --add
is run
- Make an API route for the currently logged in user to accept an invitation for a particular crate
- In a transaction:
- Add a record to the crate_owners table
- Remove the record from the crate_owner_invitations table
- In a transaction:
- On the frontend page that lists pending invitations, have a button that calls the accept API route (and displays success/error nicely, etc)
Crates.io Deployable chunk 3: Declining invitations
Still not creating records in crate_owner_invitations when cargo owner --add
is run
- Make an API route for the currently logged in user to decline an invitation for a particular crate
- Delete the crate_owner_invitations record
- On the frontend page that lists pending invitations, have a button that calls the decline API route (and displays success/error nicely, etc)
Crates.io Deployable chunk 4: Requiring approval for ownership
Assume no changes to cargo, because we can't change old cargo anyway!
- When someone runs
cargo owner --add
for a user (not a team):- Don't create a record in crate_owners, instead create a record in crate_owner_invitations
- Hopefully send a response back from crates.io that tells the person running the command that the person being added should visit the list invitations page on crates.io to accept ownership (this might not be possible depending on what cargo does today though)
- To make the approval process discoverable as the person being added to the crate from old cargo, when someone runs
cargo publish
on a crate where there's a pending invitation to add them as an owner:- Fail the publish
- Return an error message from crates.io that directs the user that they have to accept the ownership invitation first by going to the list invitations page, and then they can try publishing again
Document this requirement in the cargo owner docs (which currently live in cargo's repo)split into Document that adding someone as an owner now invites them, not adds immediately cargo#4599Super nice would be some sort of notification that shows up anywhere on crates.io and lets you know you have outstanding ownership invitations and you should go to the invitation list page to approve or decline them (thank you for this idea @natboehm!!!)split into Add some sort of notification that you have invitations to own a crate #1116
Cargo deployable chunk 5: adding CLI support for accept/decline
split into rust-lang/cargo#4600
Crates.io deployable chunk 6: UI for adding someone as an owner
split into #1117