-
Notifications
You must be signed in to change notification settings - Fork 678
Add trustpub_only flag
#12365
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
base: main
Are you sure you want to change the base?
Add trustpub_only flag
#12365
Conversation
8315034 to
4c4deb5
Compare
4c4deb5 to
1b5fb23
Compare
LawnGnome
left a comment
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.
LGTM. One or two comments, but the implementation looks good!
| && matches!(auth, AuthType::Regular(_)) | ||
| { | ||
| return Err(forbidden( | ||
| "You tried to publish with an API token but this crate requires trusted publishing.", |
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.
I think people may be confused by "API token" as a term of art, so how about:
| "You tried to publish with an API token but this crate requires trusted publishing.", | |
| "New versions of this crate can only be published using Trusted Publishing.", |
| {%- endif %} | ||
|
|
||
| {% if trustpub_only -%} | ||
| This crate can now ONLY be published via Trusted Publishing. Publishing with API tokens has been disabled. |
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.
(to follow on from my previous comment, I don't have the same concern over the use of "API token" here because the user is likely to have immediate context, since they or another owner were just thinking about trusted publishing)
| let response = user.patch::<()>(url, body.to_string()).await; | ||
| assert_snapshot!(response.status(), @"200 OK"); | ||
| assert_json_snapshot!(response.json(), { | ||
| ".crate.created_at" => "[datetime]", |
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.
Should we also explicitly be checking .crate.trustpub_only at this point? (Here and below.)
This PR implements the backend part of #12361.
It adds a new
trustpub_onlycolumn to thecratestable, exposes the field in the API responses, adjusts the publish endpoint to check it, and implements a newPATCH /api/v1/crates/{name}endpoint to toggle it.The UI implementation will follow in a dedicated PR.