Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce users.is_admin column and allow admins to yank/unyank versions #7852

Merged
merged 8 commits into from
Jan 4, 2024

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Jan 2, 2024

This PR does multiple things, but I felt that without an actual use case for admin users their introduction wouldn't make a lot of sense...

The commit messages should explain the steps, but the short version is that this PR introduces a new is_admin column on the users table, which default to false. We can manually grant this permission for the time being, and later introduce a background job that regularly syncs the data with the https://github.com/rust-lang/team/ repo.

In the next step, this PR allows users with the is_admin flag to yank/unyank crate versions that they don't own themselves. This is not granting our admins any new permissions, since such operations have previously been performed through the crates-admin yank-version admin tool already, but it reduces the amount of permissions that admin users need to have. Previously they needed full permissions on Heroku to run the admin tool, and now they only need the database flag. The PR also adds explicit logging of such an admin intervention.

The last part in this PR adds an is_admin flag to the output of /api/v1/me and then uses the field to show the yank/unyank buttons on the frontend when an admin views the version list of a crate they don't own themselves.

Lastly, note that this PR is implementing admin users slightly different from #6456. After thinking about the various implementation options it felt like a database flag with regular team repo sync might be easier than the environment variable approach, since a team repo sync in that case would need to be performed on server startup to work properly.

@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Jan 2, 2024
@Turbo87 Turbo87 requested a review from a team January 2, 2024 15:45
@Turbo87 Turbo87 merged commit fbbc857 into rust-lang:main Jan 4, 2024
7 checks passed
@Turbo87 Turbo87 deleted the admin-yanking branch January 4, 2024 10:02
@LawnGnome LawnGnome mentioned this pull request Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants