Skip to content

Commit 91f2010

Browse files
committed
Auto merge of #13351 - epage:provider, r=weihanglo
docs(ref): Try to improve reg auth docs ### What does this PR try to resolve? My end-goal *was* to discourage the use of `cargo:token` but it immediately failed for me and I need to look into that further. So this is the smaller steps I made along the way. ### How should we test and review this PR? ### Additional information For config.md, my expectation is to warn users about `cargo:token` right after the discussion on keeping tokens secret. I want to find a way to talk about this on the "your first publish" page but that needs to wait until we smooth things out.
2 parents eace48e + 5ceb1b2 commit 91f2010

File tree

2 files changed

+13
-28
lines changed

2 files changed

+13
-28
lines changed

src/doc/src/reference/config.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ Cargo will search `PATH` for its executable.
299299

300300
Configuration values with sensitive information are stored in the
301301
`$CARGO_HOME/credentials.toml` file. This file is automatically created and updated
302-
by [`cargo login`] and [`cargo logout`] when using the `cargo:token` credential provider.
302+
by [`cargo login`] and [`cargo logout`] when using the [`cargo:token`] credential provider.
303+
304+
Tokens are used by some Cargo commands such as [`cargo publish`] for
305+
authenticating with remote registries. Care should be taken to protect the
306+
tokens and to keep them secret.
303307

304308
It follows the same format as Cargo config files.
305309

@@ -311,10 +315,6 @@ token = "…" # Access token for crates.io
311315
token = "" # Access token for the named registry
312316
```
313317

314-
Tokens are used by some Cargo commands such as [`cargo publish`] for
315-
authenticating with remote registries. Care should be taken to protect the
316-
tokens and to keep them secret.
317-
318318
As with most other config values, tokens may be specified with environment
319319
variables. The token for [crates.io] may be specified with the
320320
`CARGO_REGISTRY_TOKEN` environment variable. Tokens for other registries may
@@ -1320,6 +1320,7 @@ Sets the width for progress bar.
13201320
[source replacement]: source-replacement.md
13211321
[revision]: https://git-scm.com/docs/gitrevisions
13221322
[registries]: registries.md
1323+
[`cargo:token`]: registry-authentication.md#cargotoken
13231324
[crates.io]: https://crates.io/
13241325
[target triple]: ../appendix/glossary.md#target '"target" (glossary)'
13251326
[`<triple>`]: ../appendix/glossary.md#target '"target" (glossary)'

src/doc/src/reference/registry-authentication.md

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,18 @@ which defaults to:
1919
* Unix: `~/.cargo/config.toml`
2020

2121
This recommended configuration uses the operating system provider, with a fallback to `cargo:token`
22-
to look in Cargo's [credentials](config.md#credentials) file or environment variables.
23-
24-
Some private registries may also recommend a registry-specific credential-provider. Check your
25-
registry's documentation to see if this is the case.
26-
27-
### macOS configuration
28-
```toml
29-
# ~/.cargo/config.toml
30-
[registry]
31-
global-credential-providers = ["cargo:token", "cargo:macos-keychain"]
32-
```
33-
34-
### Linux (libsecret) configuration
22+
to look in Cargo's [credentials](config.md#credentials) file or environment variables:
3523
```toml
3624
# ~/.cargo/config.toml
3725
[registry]
38-
global-credential-providers = ["cargo:token", "cargo:libsecret"]
26+
global-credential-providers = ["cargo:token", "cargo:libsecret", "cargo:macos-keychain", "cargo:wincred"]
3927
```
40-
41-
### Windows configuration
42-
```toml
43-
# %USERPROFILE%\.cargo\config.toml
44-
[registry]
45-
global-credential-providers = ["cargo:token", "cargo:wincred"]
46-
```
47-
28+
*Note that later entries have higher precedence.
4829
See [`registry.global-credential-providers`](config.md#registryglobal-credential-providers)
49-
for more details.
30+
for more details.*
31+
32+
Some private registries may also recommend a registry-specific credential-provider. Check your
33+
registry's documentation to see if this is the case.
5034

5135
## Built-in providers
5236
Cargo includes several built-in credential providers. The available built-in providers

0 commit comments

Comments
 (0)