HTTP/APACHE下的私有GIT存储库

5us2dqdw  于 2023-06-20  发布在  Git
关注(0)|答案(1)|浏览(112)

我只是想用Apache在http上做一个私有的reposity。但是当我执行git PULL时,我不能强制服务器要求用户/密码。当我按下按钮时,只询问用户/通行证。
仓库在c:/htdocs/git/test.git
我的httpd.conf:

<Directory />
    #AllowOverride none
    #Require all denied
</Directory>

SetEnv GIT_PROJECT_ROOT G:/htdocs/git
SetEnv GIT_HTTP_EXPORT_ALL
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER 

ScriptAlias /git/ "C:/Program Files (x86)/Git/libexec/git-core/git-http-backend.exe/"

<Directory "C:/Program Files (x86)/Git/libexec/git-core/">
        AllowOverride None
        Options +ExecCGI 
        Order allow,deny
        Allow from all
</Directory>

ScriptAliasMatch \
        "(?x)^/(.*/(HEAD | \
                    info/refs | \
                    objects/(info/[^/]+ | \
                             [0-9a-f]{2}/[0-9a-f]{38} | \
                             pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
                    git-(upload|receive)-pack))$" \
    "C:/Program Files (x86)/Git/libexec/git-core/git-http-backend.exe/$1"

<LocationMatch "^/.*/git-receive-pack$">
    Options +ExecCGI
    AuthType Basic
    AuthName "Git"
    AuthUserFile "G:/gitSecurity/password.git"
    Require valid-user
</LocationMatch>

我错过了什么?
谢谢!

nxowjjhe

nxowjjhe1#

刚刚解决了这个问题,我认为问题是你的LocationMatch只检查当有人推(git-receive-pack)。您需要使用一个Location指令,该指令适用于对git repos的所有访问,如

<Location "/git">
    AuthType Basic
    AuthName "Git Access"
    AuthUserFile "/var/lib/apache2/passwd/.htpasswd"
    Require valid-user
</Location>

相关问题