Skip to content

Commit 29ff25f

Browse files
committed
cleanups round 1
1 parent c2a1daa commit 29ff25f

File tree

11 files changed

+51
-21
lines changed

11 files changed

+51
-21
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ path = "src/cargo/lib.rs"
1919
bytesize = "1.0"
2020
cargo-platform = { path = "crates/cargo-platform", version = "0.1.2" }
2121
cargo-util = { path = "crates/cargo-util", version = "0.2.3" }
22-
crates-io = { path = "crates/crates-io", version = "0.35.0" }
22+
crates-io = { path = "crates/crates-io", version = "0.35.1" }
2323
curl = { version = "0.4.44", features = ["http2"] }
2424
curl-sys = "0.4.59"
2525
env_logger = "0.10.0"

crates/cargo-test-support/src/registry.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ impl RegistryBuilder {
294294
&config_path,
295295
format!(
296296
"
297-
[registries.{alternative}]
298-
index = '{}'",
297+
[registries.{alternative}]
298+
index = '{}'",
299299
registry.index_url
300300
)
301301
.as_bytes(),
@@ -306,11 +306,11 @@ impl RegistryBuilder {
306306
&config_path,
307307
format!(
308308
"
309-
[source.crates-io]
310-
replace-with = 'dummy-registry'
309+
[source.crates-io]
310+
replace-with = 'dummy-registry'
311311
312-
[registries.dummy-registry]
313-
index = '{}'",
312+
[registries.dummy-registry]
313+
index = '{}'",
314314
registry.index_url
315315
)
316316
.as_bytes(),
@@ -799,7 +799,7 @@ impl HttpServer {
799799
// todo: PASETO with challenges
800800
// - If the operation is a mutation:
801801
if let Some(mutation) = mutation {
802-
// - That the operation matches the mutation field an is one of publish, yank, or unyank.
802+
// - That the operation matches the mutation field and is one of publish, yank, or unyank.
803803
if message.mutation != Some(mutation.mutation) {
804804
dbg!(message.mutation);
805805
return false;

crates/crates-io/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "crates-io"
3-
version = "0.35.0"
3+
version = "0.35.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
repository = "https://github.com/rust-lang/cargo"

src/bin/cargo/commands/login.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,24 @@ pub fn cli() -> Command {
1111
.arg_quiet()
1212
.arg(Arg::new("token").action(ArgAction::Set))
1313
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
14-
.arg(flag("generate-keypair", "Generate a public/secret keypair").conflicts_with("token"))
1514
.arg(
16-
flag("secret-key", "Prompt for secret key")
15+
flag(
16+
"generate-keypair",
17+
"Generate a public/secret keypair (unstable)",
18+
)
19+
.conflicts_with("token"),
20+
)
21+
.arg(
22+
flag("secret-key", "Prompt for secret key (unstable)")
1723
.conflicts_with_all(&["generate-keypair", "token"]),
1824
)
1925
.arg(
20-
opt("key-subject", "Set the key subject for this registry")
21-
.value_name("SUBJECT")
22-
.conflicts_with("token"),
26+
opt(
27+
"key-subject",
28+
"Set the key subject for this registry (unstable)",
29+
)
30+
.value_name("SUBJECT")
31+
.conflicts_with("token"),
2332
)
2433
.after_help("Run `cargo help login` for more detailed information.\n")
2534
}

src/cargo/ops/registry.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,11 @@ pub fn registry_login(
807807
let new_token;
808808
if generate_keypair || secret_key_required || key_subject.is_some() {
809809
if !config.cli_unstable().registry_auth {
810-
panic!("-Zregistry_auth required.");
810+
// todo use fail_if_stable_opt
811+
bail!(
812+
"asymmetric token options are unstable and require the \
813+
`-Z registry-auth` option on the nightly channel"
814+
);
811815
}
812816
assert!(token.is_none());
813817
// we are dealing with asymmetric tokens

src/cargo/util/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
use crate::util::{config, config::ConfigKey, CanonicalUrl, CargoResult, Config, IntoUrl};
44
use anyhow::{bail, format_err, Context as _};
55
use cargo_util::ProcessError;
6-
use pasetors::paserk::FormatAsPaserk;
76
use core::fmt;
87
use pasetors::keys::{AsymmetricPublicKey, AsymmetricSecretKey};
8+
use pasetors::paserk::FormatAsPaserk;
99
use serde::Deserialize;
1010
use std::collections::HashMap;
1111
use std::error::Error;

src/doc/src/reference/unstable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ This same flag is also used to enable asymmetric authentication tokens.
903903

904904
Add support for Cargo to authenticate the user to registries without sending secrets over the network.
905905

906-
In [`config.toml`](https://doc.rust-lang.org/cargo/reference/config.html) and `credentials.toml` files there is a field called `private-key`, which 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
906+
In [`config.toml`](config.md) and `credentials.toml` files there is a field called `private-key`, which 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
907907

908908
A keypair can be generated with `cargo login --generate-keypair` which will:
909909
- generate a public/private keypair in the currently recommended fashion.

tests/testsuite/login.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,20 @@ fn bad_asymmetric_token_args() {
153153
.with_status(1)
154154
.run();
155155
}
156+
157+
// todo why do theas hang when run as a test?
158+
// #[cargo_test]
159+
// fn asymmetric_requires_nightly() {
160+
// cargo_process("login --key-subject=foo")
161+
// .with_status(101)
162+
// .with_stderr_contains("asymmetric token options are unstable and require the `-Z registry-auth` option on the nightly channel")
163+
// .run();
164+
// cargo_process("login --generate-keypair")
165+
// .with_status(101)
166+
// .with_stderr_contains("asymmetric token options are unstable and require the `-Z registry-auth` option on the nightly channel")
167+
// .run();
168+
// cargo_process("login --secret-key")
169+
// .with_status(101)
170+
// .with_stderr_contains("asymmetric token options are unstable and require the `-Z registry-auth` option on the nightly channel")
171+
// .run();
172+
// }

tests/testsuite/owner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn simple_add_with_asymmetric() {
115115
.build();
116116

117117
// The http_api server will check that the authorization is correct.
118-
// If the authorization was not sent then we wuld get an unauthorized error.
118+
// If the authorization was not sent then we would get an unauthorized error.
119119
p.cargo("owner -a username")
120120
.arg("-Zregistry-auth")
121121
.masquerade_as_nightly_cargo(&["registry-auth"])
@@ -182,7 +182,7 @@ fn simple_remove_with_asymmetric() {
182182
.build();
183183

184184
// The http_api server will check that the authorization is correct.
185-
// If the authorization was not sent then we wuld get an unauthorized error.
185+
// If the authorization was not sent then we would get an unauthorized error.
186186
p.cargo("owner -r username")
187187
.arg("-Zregistry-auth")
188188
.replace_crates_io(registry.index_url())

tests/testsuite/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ fn login_with_asymmetric_key_subject_without_key() {
11791179
.with_status(101)
11801180
.run();
11811181

1182-
// ok so ad a secret_key to the credentials
1182+
// ok so add a secret_key to the credentials
11831183
cargo_process("login --secret-key -v -Z registry-auth")
11841184
.masquerade_as_nightly_cargo(&["registry-auth"])
11851185
.replace_crates_io(registry.index_url())

0 commit comments

Comments
 (0)