Skip to content

Conversation

nathanhammond
Copy link

Two colleagues of mine spent a combined six hours yesterday trying to figure out why their custom registry was not working only to discover that it was due to the non-inclusion of Bearer as the authorization scheme in the Authorization header.

This PR is intended to present one possible path forward as a strawman for conversation in #15021.

@rustbot rustbot added A-registries Area: registries A-registry-authentication Area: registry authentication and authorization (authn authz) A-sparse-registry Area: http sparse registries labels Sep 19, 2025
@nathanhammond nathanhammond force-pushed the authorization-scheme-error branch from 8d54a17 to 98df98b Compare September 19, 2025 09:31
@epage
Copy link
Contributor

epage commented Sep 19, 2025

Some notes on contributing:

  • We'll want to see end-to-end tests for anything not already covered
    • We prefer new tests to be added in the commit before the fix with them passing, showing the current behavior. This will mean that the commit that improves the error message will also update the test, making between them show how behavior changed
  • We rely on rustc's suggestion style guide which discourages questions

} else {
write!(
f,
"Your registry token is not prefixed with an embedded authorization scheme (e.g. `Bearer `).\n\

Choose a reason for hiding this comment

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

🎉 This messaging would have saved me on the first hit :)

@nathanhammond nathanhammond force-pushed the authorization-scheme-error branch from 98df98b to efe120c Compare September 24, 2025 08:52
@rustbot rustbot added the A-testing-cargo-itself Area: cargo's tests label Sep 24, 2025
@nathanhammond nathanhammond force-pushed the authorization-scheme-error branch from efe120c to 5fcc082 Compare September 24, 2025 10:22
}
}

token_error_messages! {
Copy link
Author

@nathanhammond nathanhammond Sep 24, 2025

Choose a reason for hiding this comment

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

@epage: since this whole PR is basically test cases followed by a tiny bit of string manipulation, would you mind taking an incremental look at just the test commit?

(the tests pass, auth_required on crates.io I've not yet attempted to discover if publish --workspace can support both crates.io and custom registries simultaneously. Regardless, I started with the cross-product to fully enumerate behavior.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-registries Area: registries A-registry-authentication Area: registry authentication and authorization (authn authz) A-sparse-registry Area: http sparse registries A-testing-cargo-itself Area: cargo's tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants