2012-02-29 63 views

回答

1

您可以複製相同的身份驗證mechnism(LDAP身份驗證,在httpd.conf聲明)如果您呼叫的背後smart http mechanism,如「Setting up GIT with Apache Smart HTTP/S and LDAP」描述。

請注意,這與授權部分不同,如Gitolite: authorization vs. authentication中所述,並在「Using LDAP as auth method to manage git repositories」中進行了說明。

我更喜歡使用LDAP別名以便該驗證服務器多次引用:

<AuthnProviderAlias ldap myldap> 
    AuthLDAPBindDN cn=Manager,dc=example,dc=com 
    AuthLDAPBindPassword secret 
    AuthLDAPURL ldap://localhost:9011/dc=example,dc=com?uid?sub?(objectClass=*) 
</AuthnProviderAlias> 

這裏是一個配置(具有代替SSL)的一個例子使用LDAP:

<VirtualHost itsvcprdgit.world.company:8453> 
    ServerName itsvcprdgit.world.company 
    ServerAlias itsvcprdgit 

    SSLCertificateFile "/home/auser/compileEverything/apache/itsvcprdgit.world.company.crt" 
    SSLCertificateKeyFile "/home/auser/compileEverything/apache/itsvcprdgit.world.company.key" 
    SSLEngine on 
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL 

    SetEnv GIT_PROJECT_ROOT /home/auser/compileEverything/repositories 
    SetEnv GIT_HTTP_EXPORT_ALL 

    ScriptAlias /mygit/ /path/to/git-http-backend/ 
    <FilesMatch "\.(cgi|shtml|phtml|php)$"> 
     SSLOptions +StdEnvVars 
    </FilesMatch> 
    <Location /mygit> 
     SSLOptions +StdEnvVars 
     Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch 
     #AllowOverride All 
     order allow,deny 
     Allow from all 

     AuthName "LDAP authentication for ITSVC Smart HTTP Git repositories" 
     AuthType Basic 
     AuthBasicProvider myldap 
     AuthzLDAPAuthoritative On 

     Require valid-user 
     AddHandler cgi-script cgi 
    </Location> 
    BrowserMatch ".*MSIE.*" \ 
     nokeepalive ssl-unclean-shutdown \ 
     downgrade-1.0 force-response-1.0 
    CustomLog "/home/auser/compileEverything/apache/githttp_ssl_request_log" \ 
      "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" 
    ErrorLog "/home/auser/compileEverything/apache/githttp_error_log" 
    TransferLog "/home 
</VirtualHost> 
+0

我在我的項目中有一個基於LDAP的身份驗證示例:https://github.com/VonC/compileEverything/blob/master/apache/env.conf(但它與gitolite相關,後者依次調用cgi腳本'git-http-backend',你可以簡單地替換gitolite c全部由'git-http-backend'完成,它應該可以工作。 – VonC 2012-02-29 14:04:21

+0

也許我不理解你的conf文件,但是它會如何讓我在不同用戶的「/ git」下處理不同的git存儲庫? – 2012-02-29 15:21:01

+0

@theopulus:它將處理不同的回購,因爲'GIT_PROJECT_ROOT'告訴cgi腳本在哪裏找到它們。不同的用戶? Git並不關心,它沒有任何認證/授權機制,詳見http://stackoverflow.com/a/5685757/6309。這個'httpd.conf'只能作爲一個「檢查點」,允許訪問https:// itsvcprdgit/mygit/...到基於LDAP的認證用戶。一旦授予此https訪問權限,請求將傳遞給Git,並立即忽略用戶名。只有像Gitolite這樣的授權機制纔會使用這些信息(用戶名)。 – VonC 2012-02-29 15:36:00

相關問題