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

admin: add a new admin backend to yank and unyank crates #6811

Closed
wants to merge 3 commits into from

Conversation

LawnGnome
Copy link
Contributor

@LawnGnome LawnGnome commented Jul 15, 2023

PR administrivia

This is kind of a "draw the rest of the owl" PR. It depends on (and currently includes) these other PRs:

From there, it's hard to split anything else out, but I'll have a go if we really want that. (Maybe some of the foundational templating stuff could be separated, I guess.)

Finally, this (obviously) supersedes #6353, which I'll close momentarily. I believe I've addressed all the open points in there in some form. (And it no longer requires the awful caddy hackery used to handle my lack of knowledge of the dev server routing at the time.)

Description

This uses our existing minijinja dependency to implement a (mostly) static HTML admin console that the crates.io team can use to administer crates without needing direct database access. For now, the only administrative action allowed is yanking and unyanking crate versions, but further actions are anticipated to be added in the near future.

The spiciest part of this commit is probably the routing changes, rather than the actual templating code and controller changes, since these need to be applied across the development server, nginx, and anything else that's in front of our frontend and backend servers.

Licensing administrivia

A transitive dependency of minijinja-autoreload is licensed as CC0 OR Artistic 2.0 — AFAIK, CC0 should be fine, since it's more permissive than MIT, but I had to update our cargo-deny configuration accordingly.

Likely problems

I don't have access to Heroku and have little knowledge of our deployments, so we'll need to figure out a testing plan on staging to verify that defining admins and routing happens as we expect.

Next steps after this PR is (hopefully) merged

Here's my planned work in the near future (hopefully much faster than this project):

  • Crate deletion
  • Basic user administration
  • Quarantine admin, assuming the RFC is accepted

This adds a concept of admin users, who are defined by their GitHub IDs,
and allows them to be defined through an environment variable, falling
back to a static list of the current `crates.io` team.

`AuthCheck` now has a builder method to require that the current cookie
or token belong to an admin user.

In the future, this will be extended to use Rust's team API for the
fallback.
The existing uses of these functions meant that uses of `get` and `post`
didn't have to explicitly turbofish into `()`, but defining them this
way means they can't be used on other responses (for example, the ones
returned from `yank` and `unyank`). Moving the definitions into
`Response<T>` means we can now use these assertion helpers on any
response type, at the cost of having some more turbofish.
@LawnGnome LawnGnome added C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works A-infrastructure 📡 C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ E-big labels Jul 15, 2023
@LawnGnome LawnGnome requested a review from Turbo87 July 15, 2023 22:38
This uses our existing `minijinja` dependency to implement a (mostly)
static HTML admin console that the crates.io team can use to administer
crates without needing direct database access. For now, the only
administrative action allowed is yanking and unyanking crate versions,
but further actions are anticipated to be added in the near future.

The spiciest part of this commit is probably the routing changes, rather
than the actual templating code and controller changes, since these need
to be applied across the development server, nginx, and anything else
that's in front of our frontend and backend servers.
@LawnGnome LawnGnome self-assigned this Jul 15, 2023
@LawnGnome LawnGnome requested a review from a team July 16, 2023 21:55
Ok(Json(EncodableMe {
user: EncodablePrivateUser::from(user, email, verified, verification_sent),
user: EncodablePrivateUser::from(user, email, verified, verification_sent, admin),
Copy link
Member

Choose a reason for hiding this comment

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

this, and the corresponding frontend code changes could probably be extracted to a dedicated PR

@bors
Copy link
Contributor

bors commented Jul 18, 2023

☔ The latest upstream changes (presumably 61662dd) made this pull request unmergeable. Please resolve the merge conflicts.

@LawnGnome LawnGnome mentioned this pull request Feb 1, 2024
@LawnGnome
Copy link
Contributor Author

Obviated by #7852, #8210, and more generally by the plan in #8049.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ A-infrastructure 📡 C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear E-big
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants