Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Basic auth support? #35

Open
muscovitebob opened this issue May 8, 2020 · 9 comments
Open

Basic auth support? #35

muscovitebob opened this issue May 8, 2020 · 9 comments

Comments

@muscovitebob
Copy link

Great CLI! Does it include basic auth support? I see no references to it in the repo.

@andrewstevenson
Copy link
Contributor

You should can set it in the KAFKA_CONNECT_REST variable.

export KAFKA_CONNECT_REST="http://myserver:myport"

@muscovitebob
Copy link
Author

Indeed, this is good enough for my purposes, thanks! Although with more complex passwords including special characters I suspect this will not work.

@andreybratus
Copy link
Contributor

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?

andreybratus added a commit to andreybratus/kafka-connect-tools that referenced this issue May 11, 2020
@andreybratus
Copy link
Contributor

I am not very happy about the implementation, but it should do the job: #37

@muscovitebob
Copy link
Author

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?

@andreybratus
Copy link
Contributor

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

@muscovitebob
Copy link
Author

muscovitebob commented May 11, 2020

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.

@andreybratus
Copy link
Contributor

I suggested a quick fix here: #37

You can try to apply it or build from my fork https://github.com/andreybratus/kafka-connect-tools/tree/feature/basic-auth

@muscovitebob
Copy link
Author

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.

andrewstevenson pushed a commit that referenced this issue May 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants