feat: support cargo:token-from-stdout in private registries#2528
Merged
NobodyXu merged 5 commits intocargo-bins:mainfrom Apr 8, 2026
Merged
feat: support cargo:token-from-stdout in private registries#2528NobodyXu merged 5 commits intocargo-bins:mainfrom
cargo:token-from-stdout in private registries#2528NobodyXu merged 5 commits intocargo-bins:mainfrom
Conversation
NobodyXu
requested changes
Apr 6, 2026
Member
NobodyXu
left a comment
There was a problem hiding this comment.
Thank you!
Got one question for doc of {index_url}, one feedback that CARGO env might not set, and one feedback on code
704c670 to
c1362a4
Compare
c1362a4 to
fedf4cf
Compare
NobodyXu
requested changes
Apr 6, 2026
Member
NobodyXu
left a comment
There was a problem hiding this comment.
Thank you, just minor nit on doc and a missing optimization
NobodyXu
requested changes
Apr 7, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses #2312
Summary
This PR adds phase-2 private registry authentication support to
cargo-binstall.In this PR, "phase 2" means extending the existing private-registry auth support from
cargo:tokento Cargo's built-incargo:token-from-stdoutprovider, without yet taking on the full external credential-process surface area.Concretely, phase 2 includes:
cargo:token-from-stdoutcredential-aliasresolution forcargo:token-from-stdout--registry/--indexduringcargo installfallbackPhase 2 still does not include:
The main goal is to make private registry flows work in the same cases where
cargo installalready works withcargo:token-from-stdout, especially for registries like AWS CodeArtifact that mint short-lived tokens on demand through an external command.What Changed
cargo:token-from-stdoutsupportcargo:tokenboolean check into explicit provider resolutioncargo:token-from-stdoutprovidercredential-aliasbefore deciding whether the effective provider enables the token pathregistry.global-credential-providers, with later entries winningcargo:*provider names as built-ins, not alias targetsProvider execution behavior
{index_url}in subprocess argumentsCARGO_REGISTRY_INDEX_URLCARGO_REGISTRY_NAME_OPTFallback behavior
cargo-binstallfalls back tocargo install, it preserves the selected registry or index instead of silently defaulting back to crates.ioReal Validation
Validated manually against AWS CodeArtifact using a sparse private registry configured with
credential-provider = "cargo:token-from-stdout ..."and no pre-stored login requirement.Validation flow:
cargo:token-from-stdoutcargo install --registry private-test ...cargo-binstall --registry private-test ...cargo-binstall --forcefalls back using the same private registryObserved result:
cargo:token-from-stdoutcargo-binstallresolved the crate from CodeArtifact without401 Unauthorizedcargo installpreserved--registry private-testTest Commands
cargo test -p cargo-binstall --lib registry_auth cargo fmt --checkManual CodeArtifact smoke test:
Example registry configuration used for validation: