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

cfg4j-git doesn't support authentication with private git repositiries #180

Open
rtybase opened this issue Jul 27, 2016 · 4 comments
Open

Comments

@rtybase
Copy link

rtybase commented Jul 27, 2016

Try using cfg4j-git to access a private repository, using this demo as an example
https://github.com/cfg4j/cfg4j-sample-apps/tree/master/git-simple

First of all, there is no means to provide credentials to the private repo. Although, the underlying org.eclipse.jgit seems to parse the username and password from the repositoryURI, e.g. in CloneCommand class, line 133
URIish u = new URIish(uri);

And URIish class constructor, line 220

    matcher = FULL_URI.matcher(s);
    if (matcher.matches()) {
        scheme = matcher.group(1);
        user = unescape(matcher.group(2));
        pass = unescape(matcher.group(3));
        host = unescape(matcher.group(4));
        if (matcher.group(5) != null)
            port = Integer.parseInt(matcher.group(5));
        rawPath = cleanLeadingSlashes(
                n2e(matcher.group(6)) + n2e(matcher.group(7)), scheme);
        path = unescape(rawPath);
        return;
    }

And these details don't seem to be used at all.

Further to this problem GitConfigurationSource class, e.g. line 147

try {
  clonedRepo = Git.cloneRepository()
      .setURI(repositoryURI)
      .setDirectory(clonedRepoPath.toFile())
      .call();
} catch (GitAPIException e) {
  throw new SourceCommunicationException("Unable to clone repository: " + repositoryURI, e);
}

this doesn't inject a CredentialsProvider, like

try {
  clonedRepo = Git.cloneRepository()
      .setURI(repositoryURI)
      .setDirectory(clonedRepoPath.toFile())
      .setCredentialsProvider(credentialsProvider)
      .call();
} catch (GitAPIException e) {
  throw new SourceCommunicationException("Unable to clone repository: " + repositoryURI, e);
}

which is the right solution to sort out this problem.

@rtybase
Copy link
Author

rtybase commented Jul 27, 2016

The exceptions thrown looks like:

Exception in thread "main" org.cfg4j.source.SourceCommunicationException: Unable to communicate with configuration source: Unable to clone repository: https://bitbucket.org/....git
...
at org.cfg4j.provider.ConfigurationProviderBuilder.build(ConfigurationProviderBuilder.java:142)
...
Caused by: org.eclipse.jgit.api.errors.TransportException: https://bitbucket.org/....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.CloneCommand.fetch(CloneCommand.java:202)
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:135)
... 11 more
Caused by: org.eclipse.jgit.errors.TransportException: https://bitbucket.org/....git: Authentication is required but no CredentialsProvider has been registered
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:485)
at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:288)
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1179)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
... 14 more

@kirk-daries
Copy link

kirk-daries commented Sep 10, 2016

Just ran into this issue as well.

I installed a local gitLab repo (https://about.gitlab.com/) and tried to connect to it.
Command line cloning is working, but i'm failing to connect via SSH or HTTPS.

@Nare
Copy link

Nare commented Mar 3, 2017

Hi I would like to use cfg4j for our production servers, But this issue stops me from doing it.

  1. no way to pass git credentials. I don't want to open public access to my git repo. Of course I can set a firewall but that's not wanted.

Is this going to be fixed?

@aashishmodak
Copy link

Cant use this - as it does not support private git repos with credentials

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants