-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #10592 - arlosi:auth, r=ehuss
Implement RFC 3139: alternative registry authentication support Allows registries to request Cargo to send the authentication token for all requests, rather than just publish/yank, implementing [RFC 3139](#10474). ### Items from the [tracking issue](#10474) > Do registries need a more fine-grained switch for which API commands require authentication? This PR uses the `auth_required` boolean as described in the RFC. > The RFC mentions adding --token to additional commands like install and search These flags are not added by this PR. > Consider changing the name and form of the X- header Changed to the `www-authenticate` header as suggested by the comments. > Will there be any concerns with the interaction with rust-lang/rfcs#3231 Not that I know of. ------------- Adds a new field `"auth-required": true` to `config.json` that indicates Cargo should include the token in all requests to a registry. For HTTP registries, Cargo first attempts an un-authenticated request, then if that fails with HTTP 401, an authenticated request is attempted. The registry server may include a `www-authenticate` header with the HTTP 401 to instruct Cargo with URL the user can visit to acquire a token (crates.io/me). Since the API URL is not known (because it's stored in the index), the unstable credential provider feature is modified to key off the index url, and the registry name is no longer provided. To handle the case where an alternative registry's name is not known (such as coming from a lock file, or via `--index`), Cargo can now look up the token in the configuration by matching on the index URL. This introduces a new error if two alternative registries are configured with the same index URL. Several operations, such as `cargo install` could have had a `--token` argument added, however it appears that Cargo would like to move away from passing the token on the command line for security reasons. In this case, users would need to configure the registry via the config file (or environment variables) when using `cargo install --index ...` or similar.
- Loading branch information
Showing
42 changed files
with
1,468 additions
and
661 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
[package] | ||
name = "cargo-credential-1password" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/rust-lang/cargo" | ||
description = "A Cargo credential process that stores tokens in a 1password vault." | ||
|
||
[dependencies] | ||
cargo-credential = { version = "0.1.0", path = "../cargo-credential" } | ||
cargo-credential = { version = "0.2.0", path = "../cargo-credential" } | ||
serde = { version = "1.0.117", features = ["derive"] } | ||
serde_json = "1.0.59" |
This file contains 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
Oops, something went wrong.