@@ -334,13 +334,6 @@ impl<'cfg> HttpRegistry<'cfg> {
334
334
}
335
335
}
336
336
337
- fn check_registry_auth_unstable ( & self ) -> CargoResult < ( ) > {
338
- if self . auth_required && !self . config . cli_unstable ( ) . registry_auth {
339
- anyhow:: bail!( "authenticated registries require `-Z registry-auth`" ) ;
340
- }
341
- Ok ( ( ) )
342
- }
343
-
344
337
/// Get the cached registry configuration, if it exists.
345
338
fn config_cached ( & mut self ) -> CargoResult < Option < & RegistryConfig > > {
346
339
if self . registry_config . is_some ( ) {
@@ -486,7 +479,9 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
486
479
return Poll :: Ready ( Ok ( LoadResponse :: NotFound ) ) ;
487
480
}
488
481
StatusCode :: Unauthorized
489
- if !self . auth_required && path == Path :: new ( "config.json" ) =>
482
+ if !self . auth_required
483
+ && path == Path :: new ( "config.json" )
484
+ && self . config . cli_unstable ( ) . registry_auth =>
490
485
{
491
486
debug ! ( "re-attempting request for config.json with authorization included." ) ;
492
487
self . fresh . remove ( path) ;
@@ -542,6 +537,10 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
542
537
}
543
538
}
544
539
540
+ if !self . config . cli_unstable ( ) . registry_auth {
541
+ self . auth_required = false ;
542
+ }
543
+
545
544
// Looks like we're going to have to do a network request.
546
545
self . start_fetch ( ) ?;
547
546
@@ -587,7 +586,6 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
587
586
}
588
587
}
589
588
if self . auth_required {
590
- self . check_registry_auth_unstable ( ) ?;
591
589
let authorization =
592
590
auth:: auth_token ( self . config , & self . source_id , self . login_url . as_ref ( ) , None ) ?;
593
591
headers. append ( & format ! ( "Authorization: {}" , authorization) ) ?;
@@ -660,8 +658,10 @@ impl<'cfg> RegistryData for HttpRegistry<'cfg> {
660
658
}
661
659
662
660
fn config ( & mut self ) -> Poll < CargoResult < Option < RegistryConfig > > > {
663
- let cfg = ready ! ( self . config( ) ?) . clone ( ) ;
664
- self . check_registry_auth_unstable ( ) ?;
661
+ let mut cfg = ready ! ( self . config( ) ?) . clone ( ) ;
662
+ if !self . config . cli_unstable ( ) . registry_auth {
663
+ cfg. auth_required = false ;
664
+ }
665
665
Poll :: Ready ( Ok ( Some ( cfg) ) )
666
666
}
667
667
0 commit comments