Provide method of authentication for crate downloads #6843
Labels
A-registries
Area: registries
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
With the stabilization of alternative registries in Rust 1.34, it's now possible to connect to an alternative registry to provide an index. Since the alternative registry is a git repo, authentication can be handled in all the normal ways like SSH keypairs, git credential helpers, etc.
However, there doesn't currently seem to be a way to authenticate the downloads of the
.crate
files themselves. Once a download location is pulled from the"dl"
key in theconfig.json
provided by the index, Cargo makes a request to a URL constructed from that key. But as far as I can tell there is no way to inject any authentication information into that request. This means I need to either keep all my private.crate
artifacts on a local LAN or behind some other security like VPN.I've thought of a few workaround, but all seem hacky or have security concerns:
"dl"
URL that is time-bound and unique per user. This isn't great because it requires modifying the returned index for every user.Use git+ssh for all crate downloads and rely on keypair authThis actually wouldn't work because the download step requires https, http, or file URLs..crate
files to the local filesystem and then haveconfig.json
specify afile://
URL. This isn't good because now syncing dependencies isn't an automatic action oncargo build
, etc, it's a manual and forgettable step.I think an ideal solution would extend the usage of a token obtained through
cargo login
to also be sent during crate download requests. This would need to be handled carefully so the token is only sent over secure connections and only to download URLs for the specific registry using the token.The text was updated successfully, but these errors were encountered: