Skip to content

Conversation

@Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Nov 20, 2025

This PR implements the backend part of #12361.

It adds a new trustpub_only column to the crates table, exposes the field in the API responses, adjusts the publish endpoint to check it, and implements a new PATCH /api/v1/crates/{name} endpoint to toggle it.

The UI implementation will follow in a dedicated PR.

@Turbo87 Turbo87 added the C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works label Nov 20, 2025
@Turbo87 Turbo87 requested a review from a team November 20, 2025 15:35
Copy link
Contributor

@LawnGnome LawnGnome left a 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.",
Copy link
Contributor

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:

Suggested change
"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.
Copy link
Contributor

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]",
Copy link
Contributor

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-backend ⚙️ C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants