Git

git-http-backend, ro for all, 寫要求密碼?(使用 lighttpd)

  • April 23, 2013

我想為每個人提供對我的 GIT 儲存庫的只讀訪問權限(即不需要使用者名/密碼),但需要進行身份驗證才能寫入。git-http-backend手冊頁建議通過匹配 location 來實現這一點^/git/.*/git-receive-pack$。對於 Apache 2.x,它看起來像這樣:

<LocationMatch "^/git/.*/git-receive-pack$">
   AuthType Basic
   AuthName "Git Access"
   Require group committers
   ...
</LocationMatch>

現在,我正在使用 lighttpd,但翻譯上述內容應該不會造成問題。除了我的訪問日誌表明上述內容無論如何都行不通。這是我在執行 a 時看到的git push

192.168.1.84 tracsrv.local - [06/Apr/2013:20:00:20 +0200] "GET /git/foo.git/info/refs?service=git-receive-pack HTTP/1.1" 403 5 "-" "git/1.8.2"

所以看起來我需要匹配查詢字元串。對於輕量級,我嘗試了這個:

$HTTP["querystring"] =~ "service=git-receive-pack" {
   $HTTP["url"] =~ "^/git" {
       cgi.assign = ( "" => "" )
       setenv.add-environment = (
           "GIT_PROJECT_ROOT" => "/srv/git",
           "GIT_HTTP_EXPORT_ALL" => ""
       )

       auth.backend = "plain"
       auth.backend.plain.userfile = "/srv/tracprjs/trac.plain"
       auth.require = (
           "/" => (
               "method" => "basic",
               "realm" => "trac",
               "require" => "valid-user"
               )
           )
   }
}

$HTTP["url"] =~ "^/git" {
   cgi.assign = ( "" => "" )
   setenv.add-environment = (
       "GIT_PROJECT_ROOT" => "/srv/git",
       "GIT_HTTP_EXPORT_ALL" => ""
   )
}

不需要密碼,git fetch對於git push. 然而,git push實際上並沒有成功。關於如何實現這一目標的任何指示?

我在 git 郵件列表中的人們的幫助下找到了一個有效的配置:http ://www.spinics.net/lists/git/msg203744.html

引用自:https://serverfault.com/questions/497051