简体   繁体   English

在heroku上引入经过身份验证的git repos

[英]Pulling in authenticated git repos on heroku

I've been trying to pull in some authenticated git repos on heroku, and hit a few problems. 我一直试图在heroku上引入一些经过验证的git repos,并遇到了一些问题。

Ideally, I'd love to be able to use the token solution here git pull https://<token>@github.com/username/bar.git or even a git pull https://username:password@github.com/username/bar.git solution is acceptable if the token solution isn't. 理想情况下,我希望能够在这里使用令牌解决方案 git pull https://<token>@github.com/username/bar.git甚至是git pull https://username:password@github.com/username/bar.git如果令牌解决方案不是,则可以使用git pull https://username:password@github.com/username/bar.git解决方案。

However, it seems heroku version of git (v1.7.0) struggles with https authenticated clones: 但是,似乎heroku版本的git(v1.7.0)与https认证克隆相悖:

$ heroku run bash
$ git --version
git version 1.7.0
$ git clone https://username:password@github.com/username/bar.git
Initialized empty Git repository in /app/bevry-website/.git/
error: The requested URL returned error: 401 while accessing https://username:password@github.com/username/bar.git/info/refs
fatal: HTTP request failed

Installing a newer version of git (v1.7.12) onto the heroku instance and using that works fine: 将较新版本的git(v1.7.12)安装到heroku实例上并使用它可以正常工作:

$ heroku run bash
$ curl --silent --location http://git-core.googlecode.com/files/git-1.7.12.tar.gz | tar xz; cd git-1.7.12; make NO_TCLTK=YesPlease NO_PERL=YesPlease NO_GETTEXT=YesPlease NO_SVN_TESTS=YesPlease NO_MSGFMT=YesPlease NO_MSGFMT_EXTENDED_OPTIONS=YesPlease prefix=$HOME install; cd ..; rm -Rf git-1.7.12
$ ./bin/git --version
git version 1.7.12
$ ./bin/git clone https://username:password@github.com/username/bar.git
works fine :)

However, installing our own git version on the instance is not ideal as it takes a very long time to compile and install. 但是,在实例上安装我们自己的git版本并不理想,因为编译和安装需要很长时间。

It seems that heroku does not offer any free support, which is unfortunte as I just need to tell them to upgrade their git version and all is good. 似乎heroku不提供任何免费支持,这是不幸的,因为我只需要告诉他们升级他们的git版本,一切都很好。 However, as this is not possible, does anyone have any suggestions for doing authenticated https git clones on heroku? 但是,由于这是不可能的,有没有人有任何建议在heroku上进行经过身份验证的https git克隆? (I have managed to get authenticated ssh going by uploading a special .ssh directory with the repo, however that is not ideal for our situation as we would prefer to just use https and tokens). (我已经设法通过使用repo上传一个特殊的.ssh目录来获得经过身份验证的ssh,但这对我们的情况并不理想,因为我们更喜欢使用https和令牌)。

If the git version is indeed 1.7.0, then it is way too old, since multiple fixes were done since then the http transport mechanism. 如果git版本确实是1.7.0,那么它太旧了,因为从那时起已经完成了多次修复http传输机制。
(like 1.11.7: Pushing to smart HTTP server with recent Git fails without having the username in the URL to force authentication, if the server is configured to allow GET anonymously, while requiring authentication for POST.) (如1.11.7:如果服务器配置为匿名允许GET,同时要求对POST进行身份验证,则使用最近的Git推送到智能HTTP服务器失败而没有URL中的用户名强制进行身份验证。)

Plus 1.7.8 introduces a way to cache the credentials: Plus 1.7.8引入了一种缓存凭证的方法:

The code to handle username/password for HTTP transactions used in " git push " & " git fetch " learned to talk "credential API" to external programs to cache or store them, to allow integration with platform native keychain mechanisms. 处理“ git push ”和“ git fetch ”中使用的HTTP事务的用户名/密码的代码学会了将“凭证API”与外部程序进行对话以缓存或存储它们,以允许与平台本机密钥链机制集成。

Your ssh workaround is one way, recompiling git another, but until heroku upgrade its default git, I don't see another way to safely authenticate with https for Heroku git repos. 你的ssh解决方法是一种方法,重新编译git另一种方法,但在heroku升级其默认git之前,我没有看到另一种方法来安全地使用https进行Heroku git repos身份验证。

I just had the exact same problem: 我刚才遇到了同样的问题:

$ git clone https://username:password@github.com/username/bar.git
Initialized empty Git repository in /app/bevry-website/.git/
error: The requested URL returned error: 401 while accessing https://username:password@github.com/username/bar.git/info/refs
fatal: HTTP request failed

I used e-mail as username for Github. 我使用电子邮件作为Github的用户名。 This is not supported by Heroku's git (version 1.7). Heroku的git(版本1.7)不支持此功能。

git clone https://username:password@github.com/username/bar.git

It works, if you use the actual Github username and NOT your e-mail. 如果您使用实际的Github用户名而不是您的电子邮件,它可以工作。

The e-mail works as username with newer Git versions. 电子邮件作为新的Git版本的用户名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM