From 5e14d8aa1ba43b96bc0bdba02e328c4ce48c0883 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 13 May 2020 11:05:37 +0200 Subject: [PATCH] #35 Basic auth support (#37) --- README.md | 2 +- .../datamountaineer/connect/tools/RestKafkaConnectApi.scala | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de607b0..1fdc44f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Connect tools is Maven ## Requirements * Java 1.8 -* Gradle 3 +* Gradle 5 Kafka Connect CLI ================= diff --git a/src/main/scala/com/datamountaineer/connect/tools/RestKafkaConnectApi.scala b/src/main/scala/com/datamountaineer/connect/tools/RestKafkaConnectApi.scala index 4971ddd..3addfa3 100644 --- a/src/main/scala/com/datamountaineer/connect/tools/RestKafkaConnectApi.scala +++ b/src/main/scala/com/datamountaineer/connect/tools/RestKafkaConnectApi.scala @@ -34,7 +34,10 @@ object ScalajHttpClient extends HttpClient { */ def request(url: java.net.URI, method: String, headers: Seq[(String, String)], reqBody: Option[String]): Try[(Int, Option[String])] = { try { - val r = Http(url.toString).headers(headers) + val r = (Option(url.getUserInfo).getOrElse("").split(":") match { + case Array(user, password) => Http(url.toString).auth(user, password) + case _ => Http(url.toString) + }).headers(headers) (reqBody match { case Some(body) => r.postData(body) case None => r