-
Notifications
You must be signed in to change notification settings - Fork 208
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
add API for crates.io to trigger rebuilds #2534
Conversation
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.
some first comments.
I'm not 100% sure about the Json/APi error design, but I need a less tired moment to think about it.
As per suggestion on rust-lang#2534, although `id` was ambiguous thus using `count(*)`.
As per suggestion on rust-lang#2534, although `id` was ambiguous thus using `count(*)`.
I think I've handled all of your suggestions, but I forgot about Clippy. I'll need to get back to that another evening. |
Oh build failures:
Not sure right now what to do about this (need to stop for tonight). |
I've put the necessary command into our |
Thank you for all the work! This will be awesome for crate authors |
I've so far avoided to force-push and instead pushed 3 commits (those with subject lines starting with "sq", standing for squash) with changes that I will squash into the earlier commits where they belong; the idea is that this makes it easier for you to see what I changed; this assumes that diffing is easier as a last step after I do the squashing together with the right commits and force-pushing at the end. Let me know once you're happy and I'll do that. And if that was useful or rather a complication. |
As per suggestion on rust-lang#2534, although `id` was ambiguous thus using `count(*)`.
I've realized that you can still see the commit from before me squashing the commits anyway and have now force-pushed db8b363...b7deb0d (i.e. if you'd like to see the incremental changes I did easily, look at db8b363, for the state I wish to be merged b7deb0d). |
I've pushed 3 commits with (a) the 'optimized' SQL query, FWIW, (b)+(c) add and use the constant_time_eq crate for token comparisons. Without it, it would likely be possible for attackers to find the token via response times. |
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 looks really awesome, thank you for the continued work on this.
I'll do some local testing and then merge & deploy this.
( and probably already start using it to queue rebuilds )
@pflanze do you want to squash some commits before I merge? |
- web: `axum_cached_redirect`: change return type to be concrete - web/routes: add `post_internal` - test: add `TestFrontent::post`
This aims to satisfy these wishes: - Use the same error enum (`AxumNope`) for both handlers returning HTML or JSON. - Yet allow those handlers to specify whether HTML or JSON should be returned. - Not change the exising code returning `AxumNope`--still convert to HTML by default. Because `AxumNope` also contains a case (`Search`) that is fixed to producing HTML, but shouldn't ever be used by handlers returning JSON, that works with a runtime error in case the latter assumption isn't being followed. The approach is to add a new wrapper around `AxumNope` called `JsonAxumNope` and matching type def `JsonAxumResult`. The wrapper also implements `IntoResponse`, but produces JSON. Endpoints wishing to return JSON errors need to use that wrapper and specify `JsonAxumResult` as their return type.
This resolves rust-lang#2442. - adds config variable `DOCSRS_TRIGGER_REBUILD_TOKEN` / `Config.trigger_rebuild_token` - adds `build_trigger_rebuild_handler` and route "/crate/:name/:version/rebuild" Note: does not yet contain any kind of rate limiting!
This removes the intermediate `ErrorResponse` type and instead pattern matches AxumNope on both levels, using a new function `redirect_with_policy` to avoid duplication. (Saves 11 lines of code, 7 comment lines, and the indirection via intermediate type, but adds the function instead.)
Thank you, too, for your help during https://rustfest.ch/ and your feedback afterwards! It was the perfect introduction. Now I just need to get a bit more time. |
relates to #2442.
adds config variable
DOCSRS_TRIGGER_REBUILD_TOKEN
/Config.trigger_rebuild_token
adds
build_trigger_rebuild_handler
and route"/crate/:name/:version/rebuild"
Note: does not yet contain any kind of rate limiting!