在heroku上获得认证的git回购 [英] Pulling in authenticated git repos on heroku

查看:111
本文介绍了在heroku上获得认证的git回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



理想情况下,我希望能够使用这个功能令牌解决方案 git pull https://< token> @ github.com / username / bar.git 甚至是一个 git pull https:// username:password @ github。 com / username / bar.git 解决方案是可以接受的,如果令牌解决方案不是。



然而,似乎heroku版本的git(v1 .7.0)与经过https验证的克隆斗争:

  $ heroku运行bash 
$ git --version
git版本1.7.0
$ git克隆https://用户名:password@github.com/username/bar.git
在/app/bevry-website/.git/ $ b中初始化了空的Git仓库$ b错误:访问https://用户名:password@github.com/username/bar.git/info/refs
时,请求的URL返回错误:401致命:HTTP请求失败

$ b将新版本的git(v1.7.12)安装到heroku实例上并使用它可以正常工作:

  $ heroku运行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 =是请NO_PERL =是请NO_GETTEXT =是请NO_SVN_TESTS =是请NO_MSGFMT =是请NO_MSGFMT_EXTENDED_OPTIONS =是请前缀= $ HOME安装; cd ..; rm -Rf git-1.7.12
$ ./bin/git --version
git版本1.7.12
$ ./bin/git克隆https://用户名:密码@ github .com / username / bar.git
工作正常:)

然而,安装我们自己的git版本的实例并不理想,因为编译和安装需要很长时间。



看起来,heroku不提供任何免费支持,这是不幸的,因为我只需告诉他们升级他们的git版本,一切都很好。但是,因为这是不可能的,有没有人有任何建议在Heroku上进行身份验证的https git克隆? (我设法通过上传一个特殊的 .ssh 目录来获得认证的ssh,但是这对于我们的情况并不理想,因为我们更喜欢使用https和如果git版本确实是1.7.0,那么它太老了,因为已经完成了多个修复程序从那时起,http传输机制。
(例如1.11.7:如果服务器配置为允许匿名访问,那么使用最近的Git推送到智能HTTP服务器失败,而不在URL中具有强制认证的用户名,同时要求对POST进行身份验证。)



Plus 1.7.8引入了一种缓存凭据的方式:


处理 git push 中使用的HTTP事务的用户名/密码的代码& git fetch 学会说服凭证API到外部程序缓存或存储它们,以允许与平台本地钥匙串机制集成。


你的ssh解决方法是一种方法,重新编译git另一个方法,但在heroku升级其默认git之前,我没有看到用Heroku安全验证https的另一种方法git repos 。


I've been trying to pull in some authenticated git repos on heroku, and hit a few problems.

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.

However, it seems heroku version of git (v1.7.0) struggles with https authenticated clones:

$ 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:

$ 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.

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. However, as this is not possible, does anyone have any suggestions for doing authenticated https git clones on heroku? (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).

解决方案

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.
(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.)

Plus 1.7.8 introduces a way to cache the credentials:

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.

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.

这篇关于在heroku上获得认证的git回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆