Skip to content

Commit 6ba9828

Browse files
committed
specify the public-key format
1 parent 1f19330 commit 6ba9828

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

text/0000-cargo-asymmetric-tokens.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Private registries that require authentication use asymmetric cryptography as a
5050
3. Go to the "register a key pair" page, upload your public key. and get the user ID for that key pair.
5151

5252
Most do not, but some registries require one more step:
53+
5354
4. if the registry gave you a `key-subject` then on the command line run `cargo login --registry=name --key-subject="the provided data"`
5455

5556
There are credential processes for using key pairs stored on hardware tokens. Check crates.io to see if there's one available for your hardware. Each one is a little different, but the general workflow is:
@@ -67,13 +68,14 @@ Some registries prioritize user experience over strictest security. They can sim
6768
# Reference-level explanation
6869
[reference-level-explanation]: #reference-level-explanation
6970

71+
## Setting and storing login information
72+
7073
In [`config.toml`](https://doc.rust-lang.org/cargo/reference/config.html) and `credentials.toml` files there is a field called `private-key`, witch is a private key formatted in the secret [subset of `PASERK`](https://github.com/paseto-standard/paserk/blob/master/types/secret.md) and is used to sign asymmetric tokens
7174

7275
A keypair can be generated with `cargo login --generate-keypair` which will:
7376
- generate a public/private keypair in the currently recommended fashion.
7477
- save the private key in `credentials.toml`.
75-
- print the public key and the path to the file.
76-
(See unresolved questions section.)
78+
- print the public key in [PASERK public](https://github.com/paseto-standard/paserk/blob/master/types/public.md) format.
7779

7880
It is recommended that the `private-key` be saved in `credentials.toml`. It is also supported in `config.toml`, primarily so that it can be set using the associated environment variable. Witch is the recommended way to provide it in CI contexts. This set up is what we have for the `token` field for setting a secret token.
7981

@@ -85,6 +87,8 @@ Both fields can be set with `cargo login --registry=name --private-key="key" --p
8587

8688
A registry can have at most one of `private-key`, `token`, or `credential-process` set.
8789

90+
## The authentication process
91+
8892
When authenticating to a registry, Cargo will generate a PASETO in the [v3.public format](https://github.com/paseto-standard/paseto-spec/blob/master/docs/01-Protocol-Versions/Version3.md). This format uses P-384 and 384-bit ECDSA secret keys, and is compatible with keys stored in contemporary hardware tokens. The generated PASETO will have specific "claims" (key-value pairs in the PASETO's JSON payload). The claims within the PASETO will include at least:
8993
- The current time.
9094
- The challenge, if cargo has received a challenge from a 401/403 from this server this session. A server that issues challenges should have some stateful way of knowing which challenges have been used and which ones are still available.

0 commit comments

Comments
 (0)