vert-x3 / vertx-config

Vert.x Configuration Service
Apache License 2.0
54 stars 64 forks source link

[Git config store] Username & password authentication config is overridden by idRsa #67

Closed Trumeet closed 5 years ago

Trumeet commented 5 years ago

I'm using the config component with git config store. My config files are stored in a private git repo and I'm authentic by using username and password, which is set via:

new ConfigStoreOptions()
                        .setType("git")
                        .setConfig(new JsonObject()
                                .put("url", ...)
                                .put("path", "local")
                                .put("filesets", ...)
                                .put("user", "user")
                                .put("password", "password");

But I'm not speified a idRsaKeyPath attribute, it always says I don't provide a CredentialsProvider:

org.eclipse.jgit.api.errors.TransportException: https://github.com/xxx/xxx.git: Authentication is required but no CredentialsProvider has been registered
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:135)
    at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:267)
    at io.vertx.config.git.GitConfigStore.lambda$update$4(GitConfigStore.java:205)
    at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:272)
    at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)

I've checked the source code, these lines may overrides the pervious CredentialsProvider which is set by username and password: https://github.com/vert-x3/vertx-config/blob/037932a898fa05d98886678fdada01382359cf5e/vertx-config-git/src/main/java/io/vertx/config/git/GitConfigStore.java#L97 https://github.com/vert-x3/vertx-config/blob/037932a898fa05d98886678fdada01382359cf5e/vertx-config-git/src/main/java/io/vertx/config/git/GitConfigStore.java#L118

Is it a bug? I'm looking for your response, thanks.

cescoffier commented 5 years ago

These lines do not override the CredentialProvider. I'm more worried by https://github.com/vert-x3/vertx-config/blob/037932a898fa05d98886678fdada01382359cf5e/vertx-config-git/src/main/java/io/vertx/config/git/GitConfigStore.java#L155. We should check for null before setting them.

Can you check and open a PR?

Trumeet commented 5 years ago

@cescoffier Sorry, I'm currently not understanding these codes enough...

SINGS079 commented 5 years ago

@cescoffier @Trumeet let me take a look at this issue. If anyone is already working on this let me know here.

cescoffier commented 5 years ago

Thanks @SINGS079 !

SINGS079 commented 5 years ago

the issue is with this line where CredentialProvider is missing in case of Username and password authenticated Repo (https://github.com/vert-x3/vertx-config/blob/c8e66fec319d0215161715642f4c90399b34c227/vertx-config-git/src/main/java/io/vertx/config/git/GitConfigStore.java#L205)

I'm creating a pull request with this fix. Tested with my personal repo.

SINGS079 commented 5 years ago

Can we close this issue as this is already resolved?