@@ -304,6 +304,7 @@ pub fn cache_token(config: &Config, sid: &SourceId, token: &str) {
304
304
url. clone ( ) ,
305
305
CredentialCacheValue {
306
306
from_commandline : true ,
307
+ independent_of_endpoint : true ,
307
308
token_value : token. to_string ( ) ,
308
309
} ,
309
310
) ;
@@ -341,15 +342,18 @@ fn auth_token_optional(
341
342
if let Some ( cache_token_value) = cache. get ( url) {
342
343
// Tokens for endpoints that do not involve a mutation can always be reused.
343
344
// If the value is put in the cach by the command line, then we reuse it without looking at the configuration.
344
- if cache_token_value. from_commandline || mutation. is_none ( ) {
345
+ if cache_token_value. from_commandline
346
+ || cache_token_value. independent_of_endpoint
347
+ || mutation. is_none ( )
348
+ {
345
349
return Ok ( Some ( cache_token_value. token_value . clone ( ) ) ) ;
346
350
}
347
351
}
348
352
349
353
let credential = registry_credential_config ( config, sid) ?;
350
- let token = match credential {
354
+ let ( independent_of_endpoint , token) = match credential {
351
355
RegistryCredentialConfig :: None => return Ok ( None ) ,
352
- RegistryCredentialConfig :: Token ( config_token) => config_token. to_string ( ) ,
356
+ RegistryCredentialConfig :: Token ( config_token) => ( true , config_token. to_string ( ) ) ,
353
357
RegistryCredentialConfig :: Process ( process) => {
354
358
// todo: PASETO with process
355
359
run_command ( config, & process, sid, Action :: Get ) ?. unwrap ( )
@@ -407,18 +411,21 @@ fn auth_token_optional(
407
411
kip,
408
412
} ;
409
413
410
- pasetors:: version3:: PublicToken :: sign (
411
- & secret,
412
- serde_json:: to_string ( & message)
413
- . expect ( "cannot serialize" )
414
- . as_bytes ( ) ,
415
- Some (
416
- serde_json:: to_string ( & footer)
414
+ (
415
+ false ,
416
+ pasetors:: version3:: PublicToken :: sign (
417
+ & secret,
418
+ serde_json:: to_string ( & message)
417
419
. expect ( "cannot serialize" )
418
420
. as_bytes ( ) ,
419
- ) ,
420
- None ,
421
- ) ?
421
+ Some (
422
+ serde_json:: to_string ( & footer)
423
+ . expect ( "cannot serialize" )
424
+ . as_bytes ( ) ,
425
+ ) ,
426
+ None ,
427
+ ) ?,
428
+ )
422
429
}
423
430
} ;
424
431
@@ -427,6 +434,7 @@ fn auth_token_optional(
427
434
url. clone ( ) ,
428
435
CredentialCacheValue {
429
436
from_commandline : false ,
437
+ independent_of_endpoint,
430
438
token_value : token. to_string ( ) ,
431
439
} ,
432
440
) ;
@@ -527,7 +535,7 @@ fn run_command(
527
535
process : & ( PathBuf , Vec < String > ) ,
528
536
sid : & SourceId ,
529
537
action : Action ,
530
- ) -> CargoResult < Option < String > > {
538
+ ) -> CargoResult < Option < ( bool , String ) > > {
531
539
let index_url = sid. url ( ) . as_str ( ) ;
532
540
let cred_proc;
533
541
let ( exe, args) = if process. 0 . to_str ( ) . unwrap_or ( "" ) . starts_with ( "cargo:" ) {
@@ -552,6 +560,8 @@ fn run_command(
552
560
Action :: Erase => bail ! ( msg( "log out" ) ) ,
553
561
}
554
562
}
563
+ // todo: PASETO with process
564
+ let independent_of_endpoint = false ;
555
565
let action_str = match action {
556
566
Action :: Get => "get" ,
557
567
Action :: Store ( _) => "store" ,
@@ -622,7 +632,7 @@ fn run_command(
622
632
}
623
633
buffer. truncate ( end) ;
624
634
}
625
- token = Some ( buffer) ;
635
+ token = Some ( ( independent_of_endpoint , buffer) ) ;
626
636
}
627
637
Action :: Store ( token) => {
628
638
writeln ! ( child. stdin. as_ref( ) . unwrap( ) , "{}" , token) . with_context ( || {
0 commit comments