@@ -28,28 +28,28 @@ keyring.
28
28
[ guide-level-explanation ] : #guide-level-explanation
29
29
30
30
Suppose a user has their authentication token stored in a password manager, and
31
- the password manager provides a command, ` creds cargo` , to decrypt and print
32
- that token in a secure way. Instead of also storing the token in plaintext, the
33
- user can add this snippet to their own ` .cargo/credentials ` to authenticate
34
- with crates.io:
31
+ the password manager provides a command, ` /usr/bin/ cargo-creds ` , to decrypt and
32
+ print that token in a secure way. Instead of also storing the token in
33
+ plaintext, the user can add this snippet to their own ` .cargo/credentials ` to
34
+ authenticate with crates.io:
35
35
36
36
``` toml
37
37
[registry ]
38
- token-from-process = " creds cargo"
38
+ token-from-process = " /usr/bin/ cargo-creds "
39
39
```
40
40
41
41
When authentication is required Cargo will execute the command and use its
42
- output as the token, which will never be stored by Cargo on disk. The command
43
- will be executed inside the system's shell environment, to allow the usage of
44
- CLI utilities :
42
+ output as the token, which will never be stored by Cargo on disk. If the
43
+ command requires arguments, for example ` password-manager creds crates-io ` , you
44
+ can add them in a list :
45
45
46
46
``` toml
47
47
[registry ]
48
- token-from-process = " creds cargo | awk '{print($2)}' "
48
+ token-from-process = [ " password-manager " , " creds" , " crates-io " ]
49
49
```
50
50
51
- It will be possible to use ` token-from-process ` on both crates.io and alternative
52
- registries.
51
+ It will be possible to use ` token-from-process ` on both crates.io and
52
+ alternative registries.
53
53
54
54
# Reference-level explanation
55
55
[ reference-level-explanation ] : #reference-level-explanation
@@ -58,14 +58,16 @@ A new key, `token-from-process`, will be added to the `[registry]` and
58
58
` [registries.NAME] ` sections of the ` .cargo/credentials ` configuration file.
59
59
When a ` token ` key is also present, the latter will take precedence over
60
60
` token-from-process ` to maintain backward compatibility, and a warning will be
61
- issued to let the user know about that.
61
+ issued to let the user know about that. The ` token-from-process ` key accepts
62
+ either a string containing the binary to call or a list containing the binary
63
+ name and the arguments to provide to it.
62
64
63
65
When a ` cargo ` subcommand needs the authentication token, Cargo will execute
64
- the string contained in the configuration key with the system shell ( ` cmd.exe `
65
- on Windows and ` sh ` on other platforms ). The process will inherit Cargo's
66
- standard input and error, and the standard output will be captured by Cargo to
67
- read the token (with trimmed newlines). If the command returns an exit code
68
- other than ` 0 ` Cargo will treat that as a failure.
66
+ the binary contained in the configuration key with the defined arguments (if
67
+ provided by the user ). The process will inherit Cargo's standard input and
68
+ error, and the standard output will be captured by Cargo to read the token
69
+ (with trimmed newlines). If the command returns an exit code other than ` 0 `
70
+ Cargo will treat that as a failure.
69
71
70
72
The following environment variables will be provided to the executed command:
71
73
@@ -75,8 +77,7 @@ The following environment variables will be provided to the executed command:
75
77
# Drawbacks
76
78
[ drawbacks ] : #drawbacks
77
79
78
- This RFC requires cargo to execute a command with the system shell, which could
79
- make it more difficult to port Cargo to a new operative system without a shell.
80
+ No known drawbacks yet.
80
81
81
82
# Rationale and alternatives
82
83
[ rationale-and-alternatives ] : #rationale-and-alternatives
@@ -104,8 +105,8 @@ secret storage we expect a lot of users to use.
104
105
Multiple command line tools implement this system or a similar one to retrieve
105
106
authentication tokens or other secrets:
106
107
107
- * [ awscli] [ awscli ] includes the ` credentials_process ` setting with the same
108
- behavior as the one proposed in this RFC.
108
+ * [ awscli] [ awscli ] includes the ` credentials_process ` setting with nearly the
109
+ same behavior as the one proposed in this RFC.
109
110
* [ Docker CLI] [ docker ] offers "credential stores", programs the Docker CLI
110
111
calls with specific arguments expecting JSON output. Implementations are
111
112
provided for common storage systems, and the protocol is documented for users
0 commit comments