@@ -442,26 +442,44 @@ fn auth_token_optional(
442
442
Ok ( Some ( token) )
443
443
}
444
444
445
+ /// A record of what kind of operation is happening that we should generate a token for.
445
446
pub enum Mutation < ' a > {
447
+ /// Before we generate a crate file for the users attempt to publish,
448
+ /// we need to check if we are configured correctly to generate a token.
449
+ /// This variant is used to make sure that we can generate a token,
450
+ /// to error out early if the token is not configured correctly.
446
451
PrePublish ,
452
+ /// The user is attempting to publish a crate.
447
453
Publish {
454
+ /// The name of the crate
448
455
name : & ' a str ,
456
+ /// The version of the crate
449
457
vers : & ' a str ,
458
+ /// The checksum of the crate file being uploaded
450
459
cksum : & ' a str ,
451
460
} ,
461
+ /// The user is attempting to yank a crate.
452
462
Yank {
463
+ /// The name of the crate
453
464
name : & ' a str ,
465
+ /// The version of the crate
454
466
vers : & ' a str ,
455
467
} ,
468
+ /// The user is attempting to unyank a crate.
456
469
Unyank {
470
+ /// The name of the crate
457
471
name : & ' a str ,
472
+ /// The version of the crate
458
473
vers : & ' a str ,
459
474
} ,
475
+ /// The user is attempting to unyank a crate.
460
476
Owners {
477
+ /// The name of the crate
461
478
name : & ' a str ,
462
479
} ,
463
480
}
464
481
482
+ /// The main body of an asymmetric token as describe in RFC 3231.
465
483
#[ derive( serde:: Serialize ) ]
466
484
struct Message < ' a > {
467
485
iat : & ' a str ,
@@ -477,9 +495,11 @@ struct Message<'a> {
477
495
cksum : Option < & ' a str > ,
478
496
#[ serde( skip_serializing_if = "Option::is_none" ) ]
479
497
challenge : Option < & ' a str > ,
498
+ /// This field is not yet used. This field can be set to a value >1 to indicate a breaking change in the token format.
480
499
#[ serde( skip_serializing_if = "Option::is_none" ) ]
481
500
v : Option < u8 > ,
482
501
}
502
+ /// The footer of an asymmetric token as describe in RFC 3231.
483
503
#[ derive( serde:: Serialize ) ]
484
504
struct Footer < ' a > {
485
505
url : & ' a str ,
@@ -509,6 +529,7 @@ pub fn login(config: &Config, sid: &SourceId, token: RegistryCredentialConfig) -
509
529
Ok ( ( ) )
510
530
}
511
531
532
+ /// Checks that a secret key is valid, and returns the associated public key in Paserk format.
512
533
pub ( crate ) fn paserk_public_from_paserk_secret ( secret_key : & str ) -> Option < String > {
513
534
let secret: AsymmetricSecretKey < pasetors:: version3:: V3 > = secret_key. try_into ( ) . ok ( ) ?;
514
535
let public: AsymmetricPublicKey < pasetors:: version3:: V3 > = ( & secret) . try_into ( ) . ok ( ) ?;
0 commit comments