Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions utils/ort/src/main/kotlin/OkHttpClientHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@ val okHttpClient: OkHttpClient by lazy {
}
}.getOrThrow()
}
.addInterceptor { chain ->
val request = chain.request()

if (request.header(AUTHORIZATION_HEADER) == null) {
val credentials = requestPasswordAuthentication(request.url.toUri())
Comment on lines +130 to +131
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, this will try to authenticate any unauthenticated request, by looking up whether password authentication has been configured for the URL. This would add an overhead to any unauthenticated request, which I believe is not feasible.

if (credentials != null) {
val authenticatedRequest = request.newBuilder()
.header(
AUTHORIZATION_HEADER,
Credentials.basic(credentials.userName, String(credentials.password))
)
.build()
logger.debug { "Added AUTHORIZATION_HEADER for ${request.url.host}" }
return@addInterceptor chain.proceed(authenticatedRequest)
}
}

chain.proceed(request)
}
.cache(cache)
.connectionSpecs(specs)
.readTimeout(Duration.ofSeconds(READ_TIMEOUT_IN_SECONDS))
Expand Down
Loading