Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide method of authentication for crate downloads #6843

Closed
nastevens opened this issue Apr 12, 2019 · 5 comments
Closed

Provide method of authentication for crate downloads #6843

nastevens opened this issue Apr 12, 2019 · 5 comments
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`

Comments

@nastevens
Copy link

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 the config.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:

  • Based on authentication with the initial index provider, inject a long random string into the returned "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 auth This actually wouldn't work because the download step requires https, http, or file URLs.
  • Require a second command that syncs private registry .crate files to the local filesystem and then have config.json specify a file:// URL. This isn't good because now syncing dependencies isn't an automatic action on cargo 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.

@nastevens nastevens added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Apr 12, 2019
@ehuss ehuss added the A-registries Area: registries label Apr 12, 2019
@tustvold
Copy link
Contributor

tustvold commented Feb 8, 2020

Is there any update on this? Including the token in the request is a relatively minor change and I can't envisage it breaking anything, crates.io just ignores extraneous authorization tokens.

@ehuss
Copy link
Contributor

ehuss commented Feb 8, 2020

@tustvold There is an RFC proposal at rust-lang/rfcs#2719.

@9999years
Copy link

New RFC: rust-lang/rfcs#3139

@ehuss
Copy link
Contributor

ehuss commented Mar 12, 2022

The RFC is now accepted. Closing in favor of the tracking issue at #10474.

@ehuss ehuss closed this as completed Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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`
Projects
None yet
Development

No branches or pull requests

4 participants