Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix basic authentication during schema registry init #369

Merged
merged 3 commits into from
Mar 20, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +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.basicAuth
import io.ktor.client.request.setBody
Bdegraaf1234 marked this conversation as resolved.
Show resolved Hide resolved
import io.ktor.client.request.url
import io.ktor.http.ContentType
Expand Down Expand Up @@ -56,8 +57,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 +67,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 +95,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 Expand Up @@ -175,6 +180,7 @@ class SchemaRegistry(
val record: SpecificRecord = AvroTopic.parseSpecificRecord(topicValueSchema)
record.javaClass to record.schema
}

defaultTopic != null -> defaultTopic.valueClass to defaultTopic.valueSchema
else -> {
logger.warn(
Expand Down
Loading