通过 apache_mod_krb 进行 Git 身份验证
我正在使用 git repo 和 git-http-backend。在 apache2 中,我有位置需要克隆和推送操作的身份验证。当我使用 AuthType Basic 保护它的位置时 一切正常,git 通过身份验证,可以克隆和推送,但如果我将类型更改为 KerberosV5,git 无法使用正确的凭据访问存储库。如果我使用浏览器,我可以访问保护 kerberos 的位置。
git clone http://[email protected]/git/myapp.git
Initialized empty Git repository in /tmp/myapp/.git/
Password:
error: The requested URL returned error: 401 while accessing http://[email protected]/git/myapp.git/info/refs
fatal: HTTP request failed
并在apache错误日志中
[Fri Aug 06 17:15:50 2010] [debug] src/mod_auth_kerb.c(1579): [client 192.168.12.153] kerb_authenticate_user entered with user (NULL) and auth_type KerberosV5
[Fri Aug 06 17:15:50 2010] [debug] src/mod_auth_kerb.c(1579): [client 192.168.12.153]kerb_authenticate_user entered with user (NULL) and auth_type KerberosV5
git-core 1:1.7.1-1~bpo50+1 apache2 2.2.9-10+lenny8 libapache2-mod-auth-kerb 5.3-5
I'm using git repo with git-http-backend. In apache2 I have location what needs authentication for clone and push actions. When I protected it location with AuthType Basic
all works is fine, git passes authentication and can clone and push, but if I change type to KerberosV5 git can't access to repo with correctly credentials. If I'm using my browser I have access to location what to protect kerberos.
git clone http://[email protected]/git/myapp.git
Initialized empty Git repository in /tmp/myapp/.git/
Password:
error: The requested URL returned error: 401 while accessing http://[email protected]/git/myapp.git/info/refs
fatal: HTTP request failed
and in apache error logs
[Fri Aug 06 17:15:50 2010] [debug] src/mod_auth_kerb.c(1579): [client 192.168.12.153] kerb_authenticate_user entered with user (NULL) and auth_type KerberosV5
[Fri Aug 06 17:15:50 2010] [debug] src/mod_auth_kerb.c(1579): [client 192.168.12.153]kerb_authenticate_user entered with user (NULL) and auth_type KerberosV5
git-core 1:1.7.1-1~bpo50+1 apache2 2.2.9-10+lenny8
libapache2-mod-auth-kerb 5.3-5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 Git 2.3.1(2015 年第一季度/第二季度),这将更加强大:请参阅 commit 4dbe664< /a> 作者:brian m.卡尔森(
bk2204
):使用 Git 2.32(2021 年第 2 季度)(请参阅下面的第二部分):之前,当使用https://user:pass@site/
等 URL 访问服务器时>,在“协商”身份验证失败后,Git 不会使用嵌入在 URL 中的凭据材料回退到基本身份验证。现在(Git 2.32),Git 做到了(还没有,但很快)。请参阅 提交 1b0d954(2021 年 3 月 22 日),作者:Christopher Schenk (
chschenk
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 5013802,2021 年 3 月 30 日)但是,这仍在进行中:
请参阅 提交 ecf7b12、提交 b694f1e(2021 年 5 月 18 日),作者:杰夫·金 (
peff
)。(由 Junio C Hamano --
gitster
-- 合并于 提交 c69f2f8,2021 年 5 月 21 日)That will be more robust, with Git 2.3.1 (Q1/Q2 2015): see commit 4dbe664 by brian m. carlson (
bk2204
):It will,
with Git 2.32 (Q2 2021)(see second part below): before, when accessing a server with a URL likehttps://user:pass@site/
, Git did not to fall back to the basic authentication with the credential material embedded in the URL after the "Negotiate" authentication failed.Now (Git 2.32), Git does(not yet, but soon).See commit 1b0d954 (22 Mar 2021) by Christopher Schenk (
chschenk
).(Merged by Junio C Hamano --
gitster
-- in commit 5013802, 30 Mar 2021)However, this is still in progress:
See commit ecf7b12, commit b694f1e (18 May 2021) by Jeff King (
peff
).(Merged by Junio C Hamano --
gitster
-- in commit c69f2f8, 21 May 2021)在curl中出现问题,因为debian中的git是用curl选项ANY_AUTH编译的,当git客户端尝试连接到网络服务器并首先要求它协商身份验证但它无法做到这一点时,git不要尝试基本身份验证,因为基本身份验证的安全性较低比谈判。当我尝试使用curl --anyauth时,我也可以从网络服务器获取数据,但是如果我更改--basic一切正常,问题是我无法告诉git应该使用什么auth。
Problem in curl, because git in debian was compiled with curl option ANY_AUTH, and when git client try connect to webserver and first ask it negotiate auth and it can't do it, git don't try basic auth, because basic is lower security than negotiate. When I try curl --anyauth I can' get data from webserver too, but if I change --basic all works fine, problem in that I can't tell git what auth should use.
这是 libcurl 中的一些奇怪的事情,而不是 Git 中的问题。有一个解决方法。如果您不将用户名和密码传递给库,Libcurl 不会启用任何身份验证代码。如果您也使用不需要用户名和密码的协商(kerberos),就会发生这种情况。简单的解决方案:
x:x 是用户名和密码。您可以在那里使用任何随机字符串。只需要在 libcurl 中启用身份验证的代码路径即可。然后 kerberos 就可以工作了(对我有用:))。
It's something weird in libcurl, not a problem in Git. There is a workaround. Libcurl doesn't enable any authentication code if you don't pass username and password to the library. This happens if you use negotiate (kerberos) too which doesn't require username and password. The simple solution:
x:x is the username and password. You can use any random string there. It's only needed to enable the code path to authentication in libcurl. Then kerberos will work (works for me :) ).