@@ -136,6 +136,24 @@ enum WhyLoad {
136
136
FileDiscovery ,
137
137
}
138
138
139
+ /// A previously generated authentication token and the data needed to determine if it can be reused.
140
+ pub struct CredentialCacheValue {
141
+ /// If the command line was used to override the token then it must always be reused,
142
+ /// even if reading the configuration files would lead to a different value.
143
+ pub from_commandline : bool ,
144
+ pub token_value : String ,
145
+ }
146
+
147
+ impl fmt:: Debug for CredentialCacheValue {
148
+ /// This manual implementation helps ensure that the token value is redacted from all logs.
149
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
150
+ f. debug_struct ( "CredentialCacheValue" )
151
+ . field ( "from_commandline" , & self . from_commandline )
152
+ . field ( "token_value" , & "REDACTED" )
153
+ . finish ( )
154
+ }
155
+ }
156
+
139
157
/// Configuration information for cargo. This is not specific to a build, it is information
140
158
/// relating to cargo itself.
141
159
#[ derive( Debug ) ]
@@ -193,7 +211,7 @@ pub struct Config {
193
211
updated_sources : LazyCell < RefCell < HashSet < SourceId > > > ,
194
212
/// Cache of credentials from configuration or credential providers.
195
213
/// Maps from url to credential value.
196
- credential_cache : LazyCell < RefCell < HashMap < CanonicalUrl , ( bool , String ) > > > ,
214
+ credential_cache : LazyCell < RefCell < HashMap < CanonicalUrl , CredentialCacheValue > > > ,
197
215
/// Lock, if held, of the global package cache along with the number of
198
216
/// acquisitions so far.
199
217
package_cache_lock : RefCell < Option < ( Option < FileLock > , usize ) > > ,
@@ -468,7 +486,7 @@ impl Config {
468
486
}
469
487
470
488
/// Cached credentials from credential providers or configuration.
471
- pub fn credential_cache ( & self ) -> RefMut < ' _ , HashMap < CanonicalUrl , ( bool , String ) > > {
489
+ pub fn credential_cache ( & self ) -> RefMut < ' _ , HashMap < CanonicalUrl , CredentialCacheValue > > {
472
490
self . credential_cache
473
491
. borrow_with ( || RefCell :: new ( HashMap :: new ( ) ) )
474
492
. borrow_mut ( )
0 commit comments