@@ -80,7 +80,30 @@ ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
80
80
----------------------------------------------------------------
81
81
+
82
82
To enable anonymous read access but authenticated write access,
83
- require authorization with a LocationMatch directive:
83
+ require authorization for both the initial ref advertisement (which we
84
+ detect as a push via the service parameter in the query string), and the
85
+ receive-pack invocation itself:
86
+ +
87
+ ----------------------------------------------------------------
88
+ RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
89
+ RewriteCond %{REQUEST_URI} /git-receive-pack$
90
+ RewriteRule ^/git/ - [E=AUTHREQUIRED:yes]
91
+
92
+ <LocationMatch "^/git/">
93
+ Order Deny,Allow
94
+ Deny from env=AUTHREQUIRED
95
+
96
+ AuthType Basic
97
+ AuthName "Git Access"
98
+ Require group committers
99
+ Satisfy Any
100
+ ...
101
+ </LocationMatch>
102
+ ----------------------------------------------------------------
103
+ +
104
+ If you do not have `mod_rewrite` available to match against the query
105
+ string, it is sufficient to just protect `git-receive-pack` itself,
106
+ like:
84
107
+
85
108
----------------------------------------------------------------
86
109
<LocationMatch "^/git/.*/git-receive-pack$">
@@ -91,6 +114,15 @@ require authorization with a LocationMatch directive:
91
114
</LocationMatch>
92
115
----------------------------------------------------------------
93
116
+
117
+ In this mode, the server will not request authentication until the
118
+ client actually starts the object negotiation phase of the push, rather
119
+ than during the initial contact. For this reason, you must also enable
120
+ the `http.receivepack` config option in any repositories that should
121
+ accept a push. The default behavior, if `http.receivepack` is not set,
122
+ is to reject any pushes by unauthenticated users; the initial request
123
+ will therefore report `403 Forbidden` to the client, without even giving
124
+ an opportunity for authentication.
125
+ +
94
126
To require authentication for both reads and writes, use a Location
95
127
directive around the repository, or one of its parent directories:
96
128
+
@@ -158,6 +190,54 @@ ScriptAliasMatch \
158
190
ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/
159
191
----------------------------------------------------------------
160
192
193
+ Lighttpd::
194
+ Ensure that `mod_cgi`, `mod_alias, `mod_auth`, `mod_setenv` are
195
+ loaded, then set `GIT_PROJECT_ROOT` appropriately and redirect
196
+ all requests to the CGI:
197
+ +
198
+ ----------------------------------------------------------------
199
+ alias.url += ( "/git" => "/usr/lib/git-core/git-http-backend" )
200
+ $HTTP["url"] =~ "^/git" {
201
+ cgi.assign = ("" => "")
202
+ setenv.add-environment = (
203
+ "GIT_PROJECT_ROOT" => "/var/www/git",
204
+ "GIT_HTTP_EXPORT_ALL" => ""
205
+ )
206
+ }
207
+ ----------------------------------------------------------------
208
+ +
209
+ To enable anonymous read access but authenticated write access:
210
+ +
211
+ ----------------------------------------------------------------
212
+ $HTTP["querystring"] =~ "service=git-receive-pack" {
213
+ include "git-auth.conf"
214
+ }
215
+ $HTTP["url"] =~ "^/git/.*/git-receive-pack$" {
216
+ include "git-auth.conf"
217
+ }
218
+ ----------------------------------------------------------------
219
+ +
220
+ where `git-auth.conf` looks something like:
221
+ +
222
+ ----------------------------------------------------------------
223
+ auth.require = (
224
+ "/" => (
225
+ "method" => "basic",
226
+ "realm" => "Git Access",
227
+ "require" => "valid-user"
228
+ )
229
+ )
230
+ # ...and set up auth.backend here
231
+ ----------------------------------------------------------------
232
+ +
233
+ To require authentication for both reads and writes:
234
+ +
235
+ ----------------------------------------------------------------
236
+ $HTTP["url"] =~ "^/git/private" {
237
+ include "git-auth.conf"
238
+ }
239
+ ----------------------------------------------------------------
240
+
161
241
162
242
ENVIRONMENT
163
243
-----------
0 commit comments