Merge branch 'jk/doc-http-backend'
authorJunio C Hamano <gitster@pobox.com>
Mon, 22 Apr 2013 01:40:09 +0000 (18:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Apr 2013 01:40:09 +0000 (18:40 -0700)
Improve documentation to illustrate "push authenticated, fetch
anonymous" configuration for smart HTTP servers.

* jk/doc-http-backend:
doc/http-backend: match query-string in apache half-auth example
doc/http-backend: give some lighttpd config examples
doc/http-backend: clarify "half-auth" repo configuration

1  2 
t/lib-httpd/apache.conf
t/t5541-http-push.sh
diff --combined t/lib-httpd/apache.conf
index ad8553719a4f476bd24aa0294d4c8103d55f9d90,542241b229c96a51bc1b32d72e33b9fcb0d313be..b5bce459b61160653fcf45023f1e3c65e91f89be
@@@ -40,6 -40,9 +40,9 @@@ ErrorLog error.lo
  <IfModule !mod_authz_user.c>
        LoadModule authz_user_module modules/mod_authz_user.so
  </IfModule>
+ <IfModule !mod_authz_host.c>
+       LoadModule authz_host_module modules/mod_authz_host.so
+ </IfModule>
  </IfVersion>
  
  PassEnv GIT_VALGRIND
@@@ -61,11 -64,6 +64,11 @@@ Alias /auth/dumb/ www/auth/dumb
        SetEnv GIT_COMMITTER_NAME "Custom User"
        SetEnv GIT_COMMITTER_EMAIL custom@example.com
  </LocationMatch>
 +<LocationMatch /smart_namespace/>
 +      SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
 +      SetEnv GIT_HTTP_EXPORT_ALL
 +      SetEnv GIT_NAMESPACE ns
 +</LocationMatch>
  ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
  ScriptAlias /broken_smart/ broken-smart-http.sh/
  <Directory ${GIT_EXEC_PATH}>
@@@ -115,6 -113,21 +118,21 @@@ SSLEngine O
        Require valid-user
  </LocationMatch>
  
+ RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
+ RewriteCond %{REQUEST_URI} /git-receive-pack$
+ RewriteRule ^/half-auth-complete/ - [E=AUTHREQUIRED:yes]
+ <Location /half-auth-complete/>
+   Order Deny,Allow
+   Deny from env=AUTHREQUIRED
+   AuthType Basic
+   AuthName "Git Access"
+   AuthUserFile passwd
+   Require valid-user
+   Satisfy Any
+ </Location>
  <IfDefine DAV>
        LoadModule dav_module modules/mod_dav.so
        LoadModule dav_fs_module modules/mod_dav_fs.so
diff --combined t/t5541-http-push.sh
index 4086f02bc129b3628c724c7037fe60509fbef46c,8a9dc859317dc085dc99ddbd28eeada26c4d7d7e..beb00be4b1593a058308d8897fed81a7cf1556d7
@@@ -181,7 -181,8 +181,7 @@@ test_expect_success 'push (chunked)' 
        git checkout master &&
        test_commit commit path3 &&
        HEAD=$(git rev-parse --verify HEAD) &&
 -      git config http.postbuffer 4 &&
 -      test_when_finished "git config --unset http.postbuffer" &&
 +      test_config http.postbuffer 4 &&
        git push -v -v origin $BRANCH 2>err &&
        grep "POST git-receive-pack (chunked)" err &&
        (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
@@@ -294,5 -295,35 +294,35 @@@ test_expect_success 'push to auth-only-
        test_cmp expect actual
  '
  
+ test_expect_success 'create repo without http.receivepack set' '
+       cd "$ROOT_PATH" &&
+       git init half-auth &&
+       (
+               cd half-auth &&
+               test_commit one
+       ) &&
+       git clone --bare half-auth "$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git"
+ '
+ test_expect_success 'clone via half-auth-complete does not need password' '
+       cd "$ROOT_PATH" &&
+       set_askpass wrong &&
+       git clone "$HTTPD_URL"/half-auth-complete/smart/half-auth.git \
+               half-auth-clone &&
+       expect_askpass none
+ '
+ test_expect_success 'push into half-auth-complete requires password' '
+       cd "$ROOT_PATH/half-auth-clone" &&
+       echo two >expect &&
+       test_commit two &&
+       set_askpass user@host &&
+       git push "$HTTPD_URL/half-auth-complete/smart/half-auth.git" &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git" \
+               log -1 --format=%s >actual &&
+       expect_askpass both user@host &&
+       test_cmp expect actual
+ '
  stop_httpd
  test_done