@@ -138,7 +138,11 @@ public struct NetrcAuthorizationProvider: AuthorizationProvider {
138
138
139
139
#if canImport(Security)
140
140
public struct KeychainAuthorizationProvider : AuthorizationProvider {
141
- public init ( ) { }
141
+ private let observabilityScope : ObservabilityScope
142
+
143
+ public init ( observabilityScope: ObservabilityScope ) {
144
+ self . observabilityScope = observabilityScope
145
+ }
142
146
143
147
public func addOrUpdate( for url: Foundation . URL , user: String , password: String , callback: @escaping ( Result < Void , Error > ) -> Void ) {
144
148
guard let server = url. authenticationID else {
@@ -176,11 +180,11 @@ public struct KeychainAuthorizationProvider: AuthorizationProvider {
176
180
} catch {
177
181
switch error {
178
182
case AuthorizationProviderError . notFound:
179
- ObservabilitySystem . topScope . emit ( info: " No credentials found for server \( server) in keychain " )
183
+ self . observabilityScope . emit ( info: " No credentials found for server \( server) in keychain " )
180
184
case AuthorizationProviderError . other( let detail) :
181
- ObservabilitySystem . topScope . emit ( error: detail)
185
+ self . observabilityScope . emit ( error: detail)
182
186
default :
183
- ObservabilitySystem . topScope . emit ( error: " Failed to find credentials for server \( server) in keychain: \( error) " )
187
+ self . observabilityScope . emit ( error: " Failed to find credentials for server \( server) in keychain: \( error) " )
184
188
}
185
189
return nil
186
190
}
@@ -254,27 +258,29 @@ public struct KeychainAuthorizationProvider: AuthorizationProvider {
254
258
255
259
public struct CompositeAuthorizationProvider : AuthorizationProvider {
256
260
private let providers : [ AuthorizationProvider ]
261
+ private let observabilityScope : ObservabilityScope
257
262
258
- public init ( _ providers: AuthorizationProvider ... ) {
259
- self . init ( providers)
263
+ public init ( _ providers: AuthorizationProvider ... , observabilityScope : ObservabilityScope ) {
264
+ self . init ( providers, observabilityScope : observabilityScope )
260
265
}
261
266
262
- public init ( _ providers: [ AuthorizationProvider ] ) {
267
+ public init ( _ providers: [ AuthorizationProvider ] , observabilityScope : ObservabilityScope ) {
263
268
self . providers = providers
269
+ self . observabilityScope = observabilityScope
264
270
}
265
271
266
272
public func authentication( for url: Foundation . URL ) -> ( user: String , password: String ) ? {
267
273
for provider in self . providers {
268
274
if let authentication = provider. authentication ( for: url) {
269
275
switch provider {
270
276
case let provider as NetrcAuthorizationProvider :
271
- ObservabilitySystem . topScope . emit ( info: " Credentials for \( url) found in netrc file at \( provider. path) " )
272
- #if canImport(Security)
277
+ self . observabilityScope . emit ( info: " Credentials for \( url) found in netrc file at \( provider. path) " )
278
+ #if canImport(Security)
273
279
case is KeychainAuthorizationProvider :
274
- ObservabilitySystem . topScope . emit ( info: " Credentials for \( url) found in keychain " )
275
- #endif
280
+ self . observabilityScope . emit ( info: " Credentials for \( url) found in keychain " )
281
+ #endif
276
282
default :
277
- ObservabilitySystem . topScope . emit ( info: " Credentials for \( url) found in \( provider) " )
283
+ self . observabilityScope . emit ( info: " Credentials for \( url) found in \( provider) " )
278
284
}
279
285
return authentication
280
286
}
0 commit comments