You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/0000-cargo-alternative-registry-auth.md
+13-6Lines changed: 13 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
- Feature Name: cargo_alternative_registry_auth
2
2
- Start Date: 2021-03-31
3
-
- RFC PR: rust-lang/rfcs#0000
3
+
- RFC PR: rust-lang/rfcs#3139
4
4
- Tracking Issue: rust-lang/rust#0000
5
5
6
6
# Summary
@@ -40,13 +40,13 @@ To avoid the overhead of an extra HTTP request when fetching `config.json`, the
40
40
41
41
```toml
42
42
[registries]
43
-
my-registry = { index = "https://example.com/index", auth-required = true }
43
+
my-registry = { index = "sparse+https://example.com/index", auth-required = true }
44
44
```
45
45
46
-
## Security considerations
47
-
If the server responds with an HTTP redirect, the redirect would be followed, but the Authorization header would not be sent to the redirect target.
46
+
## Security
47
+
If the server responds with an HTTP redirect, the redirect would be followed, but the Authorization header would *not* be sent to the redirect target.
48
48
49
-
The authorization header would only be included for requests using `https` or requests targeting `localhost`. If cargo detected an alternative registry was configured to send the authorization token over an insecure channel, it would exit with an error informing the user.
49
+
The authorization header would only be included for requests using `https://`. Under no circumstances would cargo pass an authorization header over an unencrypted `http://` connection. If cargo detected an alternative registry was configured to send the authorization token over an insecure channel, it would exit with an error.
50
50
51
51
## Interaction with `credential-process`
52
52
The unstable [credential-process](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#credential-process) feature stores credentials keyed on the registry api url, which is only available in after fetching `config.json` from the index. If access to the index is secured using the authorization token, then Cargo will be unable to fetch the `config.json` file before calling the credential process.
@@ -58,6 +58,7 @@ To resolve this issue, the credential process feature would use the registry *in
58
58
59
59
Since the token may be used multiple times in a single cargo session (such as updating the index + downloading crates), Cargo should cache the token if it is provided by a `credential-process` to avoid repeatedly calling the credential process.
60
60
61
+
61
62
## Command line options
62
63
Cargo commands such as `install` or `search` that support an `--index <INDEX>` command line option to use a registry other than what is available in the configuration file would gain a `--token <TOKEN>` command line option (similar to `publish` today). If a `--token <TOKEN>` command line option is given, the provided authorization token would be sent along with the request.
63
64
@@ -97,4 +98,10 @@ Alternatives:
97
98
# Future possibilities
98
99
[future-possibilities]: #future-possibilities
99
100
100
-
The `credential-process` system could be extended to support generating tokens rather than only storing them. This would further improve security and allow additional features such as 2FA prompts.
101
+
## Credential Process
102
+
The `credential-process` system could be extended to support generating tokens rather than only storing them. This would further improve security and allow additional features such as 2FA prompts.
103
+
104
+
## Authentication for Git-based registries
105
+
Private registries may want to use the same Authorization header for controlling access to a git-based index over `https`, rather than letting git handle the authentication separately.
106
+
107
+
This could be enabled by the same local configuration key `auth-required = true` in the `[registries]` table. Both `libgit2` and the `git` command line have a mechanism for specifying an additional header that could be used to pass the Authorization header.
0 commit comments