-
Notifications
You must be signed in to change notification settings - Fork 620
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
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
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
force-pushed
the
admin-minininja
branch
from
July 15, 2023 22:50
2bf7866
to
0a28df6
Compare
Turbo87
reviewed
Jul 17, 2023
Ok(Json(EncodableMe { | ||
user: EncodablePrivateUser::from(user, email, verified, verification_sent), | ||
user: EncodablePrivateUser::from(user, email, verified, verification_sent, admin), |
There was a problem hiding this comment.
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
☔ The latest upstream changes (presumably 61662dd) made this pull request unmergeable. Please resolve the merge conflicts. |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR administrivia
This is kind of a "draw the rest of the owl" PR. It depends on (and currently includes) these other PRs:
AuthCheck
to handle them #6456assert_forbidden
andassert_not_found
for any response #6585From 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):