Skip to content

Commit

Permalink
Fix basic authentication during schema registry init
Browse files Browse the repository at this point in the history
  • Loading branch information
pvannierop committed Mar 19, 2024
1 parent f8523a5 commit 9437b4d
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ package org.radarbase.schema.registration
import io.ktor.client.plugins.auth.Auth
import io.ktor.client.plugins.auth.providers.BasicAuthCredentials
import io.ktor.client.plugins.auth.providers.basic
import io.ktor.client.request.setBody
import io.ktor.client.request.url
import io.ktor.client.request.*
import io.ktor.http.ContentType
import io.ktor.http.HttpMethod
import io.ktor.http.contentType
Expand Down Expand Up @@ -56,8 +55,8 @@ import kotlin.time.toKotlinDuration
*/
class SchemaRegistry(
private val baseUrl: String,
apiKey: String? = null,
apiSecret: String? = null,
private val apiKey: String? = null,
private val apiSecret: String? = null,
private val topicConfiguration: Map<String, TopicConfig> = emptyMap(),
) {
private val schemaClient: SchemaRetriever = schemaRetriever(baseUrl) {
Expand All @@ -66,6 +65,7 @@ class SchemaRegistry(
if (apiKey != null && apiSecret != null) {
install(Auth) {
basic {
sendWithoutRequest { true }
credentials {
BasicAuthCredentials(username = apiKey, password = apiSecret)
}
Expand Down Expand Up @@ -93,6 +93,9 @@ class SchemaRegistry(
try {
httpClient.request<List<String>> {
url("subjects")
if (apiKey != null && apiSecret != null) {
basicAuth(apiKey, apiSecret)
}
}
} catch (ex: RestException) {
logger.error(
Expand Down

0 comments on commit 9437b4d

Please sign in to comment.