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

GitHub for repository type git doesn't use setup authentication for https://github.com/acme/private-repository #8414

Open
glaubinix opened this issue Nov 6, 2019 · 4 comments
Labels
Bug

Comments

@glaubinix
Copy link
Contributor

@glaubinix glaubinix commented Nov 6, 2019

Hello,

If I add a private GitHub repository as type git with a url like https://github.com/acme-org/my-private-repository then composer will fail if my ssh key doesn't have access to the GitHub repository, even if I have a GitHub token defined in my auth.json. Access with the token works when using https://MY_GITHUB_TOKEN@github.com/acme-org/my-private-repository but the composer GitDriver is not trying to access it.

My composer.json:

{
    "repositories": [
        {"type": "git", "url":  "https://github.com/acme-org/my-private-repository"}
    ],
    "require": {
        "acme-org/my-private-repository": "dev-master"
    }
}

My auth.json:

{
    "github-oauth": {
        "github.com": "MY_GITHUB_TOKEN"
    }
}

When I run this command:

composer install/update

I get the following output:

composer install
Loading composer repositories with package information


  [RuntimeException]
  Failed to clone https://github.com/acme-org/my-private-re
  pository via https, ssh protocols, aborting.

  - https://github.com/acme-org/my-private-repository
    Cloning into bare repository '/Path/to/.compose
  r/cache/vcs/https---github.com-acme-org-my-private-reposi
  tory'...
    remote: Invalid username or password.
    fatal: Authentication failed for 'https://github.com/ac
  me-org/my-private-repository/'

  - git@github.com:acme-org/my-private-repository
    Cloning into bare repository '/Path/to/.compose
  r/cache/vcs/https---github.com-acme-org-my-private-reposi
  tory'...
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

And I expected this to happen:

Composer install/update should use the GitHub authentication as defined in the auth.json for git if defined.

@stof

This comment has been minimized.

Copy link
Contributor

@stof stof commented Nov 6, 2019

can you try with the latest snapshot version (install it with composer self-update --snapshot; you can revert to another release channel later using that command again with the right flag) ? @Seldaek made some fixes recently regarding the github/gitlab/bitbucket auth.

@glaubinix

This comment has been minimized.

Copy link
Contributor Author

@glaubinix glaubinix commented Nov 6, 2019

sorry, forgot to add that information. This happens with Composer version 1.10-dev (1.10-dev+7e929503671fc94de8ba16d665936e63f46d5a56) 2019-11-06 10:27:40 but also latest stable. From what I can see in the git log the GitDriver was last edited 9 months ago.

@Seldaek

This comment has been minimized.

Copy link
Member

@Seldaek Seldaek commented Nov 6, 2019

I was hoping the recent change done at https://github.com/composer/composer/blob/master/src/Composer/Util/Git.php#L99-L118 would fix this.. The idea was that it should try authenticating the commands via this.. but maybe it fails when coming from GitDriver, or due to something else I don't have in mind right now.

@glaubinix

This comment has been minimized.

Copy link
Contributor Author

@glaubinix glaubinix commented Nov 6, 2019

I think the problem is that it doesn't even get that far because the if before throws the exception if it matches the https url scheme: https://github.com/composer/composer/blob/master/src/Composer/Util/Git.php#L69-L89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.