kafka-connect-tools
kafka-connect-tools copied to clipboard
Basic auth support?
Great CLI! Does it include basic auth support? I see no references to it in the repo.
You should can set it in the KAFKA_CONNECT_REST variable.
export KAFKA_CONNECT_REST="http://myserver:myport"
Indeed, this is good enough for my purposes, thanks! Although with more complex passwords including special characters I suspect this will not work.
You should can set it in the KAFKA_CONNECT_REST variable.
export KAFKA_CONNECT_REST="http://myserver:myport"I don't think passing basic auth in the url works with the current implementation.
@muscovitebob, can you confirm it?
I am not very happy about the implementation, but it should do the job: https://github.com/lensesio/kafka-connect-tools/pull/37
I am having a bit of an issue with building the project to test it. I've obtained Gradle 5 and am following the readme. From the project dir I do:
gradle-5.6.4/bin/gradle buildCli
Which returns:
> Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> Could not find matching constructor for: org.gradle.process.internal.DefaultExecActionFactory(org.gradle.api.internal.file.BaseDirFileResolver)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Does this look familiar?
I had a similar issue. I reckon it's related to gradle version and incompatibility of some plugin, most likely scalatest gradle plugin. Try using the gradlew wrapper.
./gradlew clean buildCli
Thanks, that helped. Testing against my Kafka Connect cluster, which is HTTPs and secured with BasicAuth. I have the following format of env variable:
export KAFKA_CONNECT_REST='https://USERNAME:ALPHANUMERICPASSWORD@HOSTNAME:PORT'
Then running:
./gradlew clean buildCli
bin/connect-cli ps
Yields:
java.lang.Exception: Error: the Kafka Connect API returned status code 401
at com.datamountaineer.connect.tools.RestKafkaConnectApi.non2xxException(RestKafkaConnectApi.scala:124)
at com.datamountaineer.connect.tools.RestKafkaConnectApi.com$datamountaineer$connect$tools$RestKafkaConnectApi$$req(RestKafkaConnectApi.scala:141)
at com.datamountaineer.connect.tools.RestKafkaConnectApi$$anonfun$activeConnectorNames$1.apply(RestKafkaConnectApi.scala:153)
at com.datamountaineer.connect.tools.RestKafkaConnectApi$$anonfun$activeConnectorNames$1.apply(RestKafkaConnectApi.scala:152)
at scala.util.Try$.apply(Try.scala:192)
at com.datamountaineer.connect.tools.RestKafkaConnectApi.activeConnectorNames(RestKafkaConnectApi.scala:152)
at com.datamountaineer.connect.tools.ExecuteCommand$.apply(Cli.scala:66)
at com.datamountaineer.connect.tools.Cli$.main(Cli.scala:209)
at com.datamountaineer.connect.tools.Cli.main(Cli.scala)
And to make sure it is not an issue with the bash variable, running:
curl -X GET ${KAFKA_CONNECT_REST}
Indeed returns information about my Kafka Connect cluster.
So it appears that some logic in current master is stripping the credentials info out of the URL string.
I suggested a quick fix here: https://github.com/lensesio/kafka-connect-tools/pull/37
You can try to apply it or build from my fork https://github.com/andreybratus/kafka-connect-tools/tree/feature/basic-auth
Checked out the fork/branch and can confirm that at least with ps it works. I will test the other commands later but looking at the code as the request method is used in all the methods I do not anticipate any issues. Thanks @andreybratus ! Might still be an issue if the password includes : however.