有没有使用LDAP作为认证方法来管理Git存储库的经验,我的老板更喜欢使用LDAP而不是其他工具。任何建议都将是有帮助的!更详细的信息将非常受欢迎。
你可以很容易地将LDAP身份验证添加到Apache Httpd服务器中。
并且你可以很容易地添加一个smart http CGI脚本'git-http-backend'(与git一起打包)
这意味着,只要你先输入了LDAP凭据,就可以推送到https地址。你被授权访问Apache页面,但认证根本没有被使用。
请参见" mod_authn_ldap和mod_authz_ldap之间的区别"
然而:
实际使用身份验证并与Git授权访问结合的唯一方法是使用Gitolite。
例如,请参见“使存储库对ssh和http模式客户端都可用”。
我已经设置了(multiple)LDAP身份验证的gitolite,将身份验证步骤放在Apache配置文件中,然后使用识别的用户作为参数调用gitolite:
首先,我声明LDAP别名:
<AuthnProviderAlias ldap myldap>
AuthLDAPBindDN cn=Manager,dc=example,dc=com
AuthLDAPBindPassword secret
AuthLDAPURL ldap://localhost:@PORT_LDAP_TEST@/dc=example,dc=com?uid?sub?(objectClass=*)
</AuthnProviderAlias>
<AuthnProviderAlias ldap companyldap>
AuthLDAPBindDN "@LDAP_BINDDN@"
AuthLDAPBindPassword @LDAP_PASSWORD@
AuthLDAPURL @LDAP_URL@
</AuthnProviderAlias>
("@xx@
" 是要被测试或生产值替换的模板)
然后,如果身份验证成功,我在一个VirtualHost
中调用gitolite
,使用这些别名
# GitHttp on @PORT_HTTP_HGIT@ (extract)
Listen @PORT_HTTP_HGIT@
<VirtualHost @FQN@:@PORT_HTTP_HGIT@>
ServerName @FQN@
ServerAlias @HOSTNAME@
SetEnv GIT_PROJECT_ROOT @H@/repositories
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv GITOLITE_HTTP_HOME @H@
ScriptAlias /hgit/ @H@/sbin/gitolite-shell/ # <=== will call gitolite
SetEnv GIT_HTTP_BACKEND "@H@/usr/local/apps/git/libexec/git-core/git-http-backend"
<Location /hgit>
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
#AllowOverride All
order allow,deny
Allow from all
AuthName "LDAP authentication for ITSVC Smart HTTP Git repositories"
AuthType Basic
# Authentication against one ldap, then a second
AuthBasicProvider myldap companyldap
AuthzLDAPAuthoritative Off
Require valid-user
AddHandler cgi-script cgi
</Location>
</VirtualHost>
由于您提到了OpenLDAP,我假设您想在Unix/Linux环境中实现这个功能。
据我所知,Git本身并不进行身份验证。您需要设置ldap来管理访问git存储库的服务。例如,如果您使用SSH,则配置您的SSH守护程序以对ldap进行身份验证。
如何精确配置取决于您使用的确切设置。如果您需要帮助,请建议在serverfault.com上发布详细的问题。
您还可能会发现this related question有趣。