OSDN Git Service

Update Document
[tortoisegit/TortoiseGitJp.git] / doc / source / en / TortoiseGit / tsvn_server / server_apache.xml
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE sect1 SYSTEM "../../../dtd/dblite.dtd">\r
3 <sect1 id="tsvn-serversetup-apache">\r
4         <title>Apache Based Server</title>\r
5         <sect2 id="tsvn-serversetup-apache-1">\r
6                 <title>Introduction</title>\r
7                 <indexterm>\r
8                         <primary>Apache</primary>\r
9                 </indexterm>\r
10                 <para>\r
11                         The most flexible of all possible server setups for Git\r
12                         is the Apache based one. Although a bit more complicated to set up,\r
13                         it offers benefits that other servers cannot:\r
14                 </para>\r
15                 <indexterm>\r
16                         <primary>WebDAV</primary>\r
17                 </indexterm>\r
18                 <variablelist>\r
19                         <varlistentry>\r
20                                 <term>WebDAV</term>\r
21                                 <listitem>\r
22                                         <para>\r
23                                                 The Apache based Git server uses the\r
24                                                 WebDAV protocol which is supported by many other\r
25                                                 programs as well. You could e.g. mount such\r
26                                                 a repository as a <quote>Web folder</quote> in the Windows\r
27                                                 explorer and then access it like any other\r
28                                                 folder in the file system.\r
29                                         </para>\r
30                                 </listitem>\r
31                         </varlistentry>\r
32                         <varlistentry>\r
33                                 <term>Browsing The Repository</term>\r
34                                 <listitem>\r
35                                         <para>\r
36                                                 You can point your browser to the URL of your\r
37                                                 repository and browse the contents of it without\r
38                                                 having a Git client installed. This\r
39                                                 gives access to your data to a much wider circle of\r
40                                                 users.\r
41                                         </para>\r
42                                 </listitem>\r
43                         </varlistentry>\r
44                         <varlistentry>\r
45                                 <term>Authentication</term>\r
46                                 <listitem>\r
47                                         <para>\r
48                                                 You can use any authentication mechanism Apache\r
49                                                 supports, including SSPI and LDAP.\r
50                                         </para>\r
51                                 </listitem>\r
52                         </varlistentry>\r
53                         <varlistentry>\r
54                                 <term>Security</term>\r
55                                 <listitem>\r
56                                         <para>\r
57                                                 Since Apache is very stable and secure,\r
58                                                 you automatically get the same security for your\r
59                                                 repository. This includes SSL encryption.\r
60                                         </para>\r
61                                 </listitem>\r
62                         </varlistentry>\r
63                 </variablelist>\r
64         </sect2>\r
65         <sect2 id="tsvn-serversetup-apache-2">\r
66                 <title>Installing Apache</title>\r
67                 <para>\r
68                         The first thing you need before installing Apache is a computer\r
69                         with Windows 2000, Windows XP+SP1, Windows 2003, Vista or Server 2008.\r
70                         <warning>\r
71                                 <para>\r
72                                         Please note that Windows XP without the service pack 1\r
73                                         will lead to bogus network data and could therefore\r
74                                         corrupt your repository!\r
75                                 </para>\r
76                         </warning>\r
77                         <orderedlist>\r
78                                 <listitem>\r
79                                         <para>\r
80                                                 Download the latest version of the Apache\r
81                                                 web server from\r
82                                                 <ulink url="http://httpd.apache.org/download.cgi">\r
83                                                         <citetitle>http://httpd.apache.org/download.cgi</citetitle>\r
84                                                 </ulink>.\r
85                                                 Make sure that you download the version 2.2.x -\r
86                                                 the version 1.3.xx won't work!\r
87                                         </para>\r
88                                         <para>\r
89                                                 The msi installer for Apache can be found by clicking on <literal>other files</literal>,\r
90                                                 then browse to <filename>binaries/win32</filename>. You may want to choose\r
91                                                 the msi file <filename>apache-2.2.x-win32-x86-openssl-0.9.x.msi</filename>\r
92                                                 (the one that includes OpenSSL).\r
93                                         </para>\r
94                                 </listitem>\r
95                                 <listitem>\r
96                                         <para>\r
97                                                 Once you have the Apache2 installer you\r
98                                                 can double click on it and it will guide you through\r
99                                                 the installation process. Make sure that you enter\r
100                                                 the server-URL correctly (if you don't have a DNS name\r
101                                                 for your server just enter the IP-address). I recommend\r
102                                                 to install Apache\r
103                                                 <emphasis>for All Users, on Port 80, as a Service</emphasis>.\r
104                                                 Note: if you already have IIS or any other\r
105                                                 program running which listens on port 80 the\r
106                                                 installation might fail. If that happens, go to the\r
107                                                 programs directory,\r
108                                                 <filename>\Apache Group\Apache2\conf</filename>\r
109                                                 and locate the file\r
110                                                 <filename>httpd.conf</filename>. Edit that file so that\r
111                                                 <literal>Listen 80</literal> is changed to a free\r
112                                                 port, e.g. <literal>Listen 81</literal>.\r
113                                                 Then restart the installation - this time it should\r
114                                                 finish without problems.\r
115                                         </para>\r
116                                 </listitem>\r
117                                 <listitem>\r
118                                         <para>\r
119                                                 Now test if the Apache web server is running\r
120                                                 correctly by pointing your web browser to\r
121                                                 <systemitem class="url">http://localhost/</systemitem>\r
122                                                 - a preconfigured Website should show up.\r
123                                         </para>\r
124                                 </listitem>\r
125                         </orderedlist>\r
126                         <caution>\r
127                                 <para>\r
128                                         If you decide to install Apache as a service, be warned that\r
129                                         by default it will run as the local system account.\r
130                                         It would be a more secure practice for you to create a\r
131                                         separate account for Apache to run as.\r
132                                 </para>\r
133                                 <para>\r
134                                         Make sure that the account on the server that Apache is running as\r
135                                         has an explicit entry in the repository directory's access control \r
136                                         list (right-click directory | properties | security), with full \r
137                                         control.  Otherwise, users will not be able to commit their changes.\r
138                                 </para>\r
139                                 <para>\r
140                                         Even if Apache runs as local system, you still need such an entry \r
141                                         (which will be the SYSTEM account in this case).\r
142                                 </para>\r
143                                 <para>\r
144                                         If Apache does not have this permission set up, your users will get \r
145                                         <quote>Access denied</quote> error messages, which show up in the Apache error log \r
146                                         as error 500.\r
147                                 </para>\r
148                         </caution>\r
149                 </para>\r
150         </sect2>\r
151         <sect2 id="tsvn-serversetup-apache-3">\r
152                 <title>Installing Git</title>\r
153                 <para>\r
154                         <orderedlist>\r
155                                 <listitem>\r
156                                         <para>\r
157                                                 Download the latest version of the Git Win32 binaries for\r
158                                                 Apache. Be sure to get the right version to integrate with your\r
159                                                 version of Apache, otherwise you will get an obscure error\r
160                                                 message when you try to restart.\r
161                                                 If you have Apache 2.2.x go to\r
162                                                 <ulink url="http://Git.tigris.org/servlets/ProjectDocumentList?folderID=8100">\r
163                                                         <citetitle>http://Git.tigris.org/servlets/ProjectDocumentList?folderID=8100</citetitle>\r
164                                                 </ulink>.\r
165                                         </para>\r
166                                 </listitem>\r
167                                 <listitem>\r
168                                         <para>\r
169                                                 Run the Git installer and follow\r
170                                                 the instructions. If the Git installer recognized\r
171                                                 that you've installed Apache, then you're almost done.\r
172                                                 If it couldn't find an Apache server then you have to\r
173                                                 do some additional steps.\r
174                                         </para>\r
175                                 </listitem>\r
176                                 <listitem>\r
177                                         <indexterm>\r
178                                                 <primary>mod_authz_svn</primary>\r
179                                         </indexterm>\r
180                                         <para>\r
181                                                 Using the windows explorer, go to the installation\r
182                                                 directory of Git (usually\r
183                                                 <filename>c:\program files\Git</filename>)\r
184                                                 and find the files\r
185                                                 <filename>/httpd/mod_dav_svn.so</filename> and\r
186                                                 <filename>mod_authz_svn.so</filename>. Copy these files\r
187                                                 to the Apache modules directory (usually\r
188                                                 <filename>c:\program files\apache group\apache2\modules\r
189                                                 </filename>).\r
190                                         </para>\r
191                                 </listitem>\r
192                                 <listitem>\r
193                                         <para>\r
194                                                 Copy the file <filename>/bin/libdb*.dll</filename>\r
195                                                 and <filename>/bin/intl3_svn.dll</filename> from\r
196                                                 the Git installation directory to the Apache\r
197                                                 bin directory.\r
198                                         </para>\r
199                                 </listitem>\r
200                                 <listitem>\r
201                                         <para>\r
202                                                 Edit Apache's configuration file (usually <filename>\r
203                                                 C:\Program Files\Apache\r
204                                                 Group\Apache2\conf\httpd.conf</filename>) with a text\r
205                                                 editor such as Notepad and make the following changes:\r
206                                         </para>\r
207                                         <para>\r
208                                                 Uncomment (remove the '<literal>#</literal>' mark) the\r
209                                                 following lines:\r
210 <screen>\r
211 #LoadModule dav_fs_module modules/mod_dav_fs.so\r
212 #LoadModule dav_module modules/mod_dav.so\r
213 </screen>\r
214                                                 Add the following two lines to the end of the\r
215                                                 <literal>LoadModule</literal> section.\r
216 <screen>\r
217 LoadModule dav_svn_module modules/mod_dav_svn.so\r
218 LoadModule authz_svn_module modules/mod_authz_svn.so\r
219 </screen>\r
220                                         </para>\r
221                                 </listitem>\r
222                         </orderedlist>\r
223                 </para>\r
224         </sect2>\r
225         <sect2 id="tsvn-serversetup-apache-4">\r
226                 <title>Configuration</title>\r
227                 <para>\r
228                         Now you have set up Apache and Git, but Apache doesn't\r
229                         know how to handle Git clients like TortoiseGit yet.\r
230                         To get Apache to know which URL will be used for Git\r
231                         repositories you have to edit the Apache configuration file (usually\r
232                         located in\r
233                         <filename>c:\program files\apache group\apache2\conf\httpd.conf</filename>)\r
234                         with any text editor you like (e.g. Notepad):\r
235                 <orderedlist>\r
236                                 <listitem>\r
237                                         <para>\r
238                                                 At the end of the config file add the following lines:\r
239 <screen>\r
240 &lt;Location /svn&gt;\r
241   DAV svn\r
242   SVNListParentPath on\r
243   SVNParentPath D:\SVN\r
244   #SVNIndexXSLT "/svnindex.xsl"\r
245   AuthType Basic\r
246   AuthName "Git repositories"\r
247   AuthUserFile passwd\r
248   #AuthzSVNAccessFile svnaccessfile\r
249   Require valid-user\r
250 &lt;/Location&gt;\r
251 </screen>\r
252                                                 This configures Apache so that all your Git\r
253                                                 repositories are physically located below\r
254                                                 <filename>D:\SVN</filename>. The repositories are\r
255                                                 served to the outside world from the URL:\r
256                                                 <systemitem class="url">\r
257                                                         http://MyServer/svn/\r
258                                                 </systemitem>.\r
259                                                 Access is restricted to known users/passwords \r
260                                                 listed in the <filename>passwd</filename> file.\r
261                                         </para>\r
262                                 </listitem>\r
263                                 <listitem>\r
264                                         <para>\r
265                                                 To create the <filename>passwd</filename>\r
266                                                 file, open the command prompt (DOS-Box) again,\r
267                                                 change to the <filename>apache2</filename> folder (usually\r
268                                                 <filename>c:\program files\apache\r
269                                                 group\apache2</filename>)\r
270                                                 and create the file by entering\r
271 <screen>\r
272 bin\htpasswd -c passwd &lt;username&gt;\r
273 </screen>\r
274                                                 This will create a file with the name <filename>passwd</filename> which is\r
275                                                 used for authentication. Additional users can be added\r
276                                                 with\r
277 <screen>\r
278 bin\htpasswd passwd &lt;username&gt;\r
279 </screen>\r
280                                         </para>\r
281                                 </listitem>\r
282                                 <listitem>\r
283                                         <para>\r
284                                                 Restart the Apache service again.\r
285                                         </para>\r
286                                 </listitem>\r
287                                 <listitem>\r
288                                         <para>\r
289                                                 Point your browser to\r
290                                                 <systemitem class="url">http://MyServer/svn/MyNewRepository</systemitem>\r
291                                                 (where <filename>MyNewRepository</filename> is the name of the\r
292                                                 Git repository you created before). If all went\r
293                                                 well you should be prompted for a username and password,\r
294                                                 then you can see the contents of your\r
295                                                 repository.\r
296                                         </para>\r
297                                 </listitem>\r
298                         </orderedlist>\r
299                 </para>\r
300                 <indexterm>\r
301                         <primary>SVNPath</primary>\r
302                 </indexterm>\r
303                 <indexterm>\r
304                         <primary>SVNParentPath</primary>\r
305                 </indexterm>\r
306                 <para>\r
307                         A short explanation of what you just entered:\r
308                         <table id="tsvn-serversetup-apache-4-table">\r
309                                 <title>Apache <filename>httpd.conf</filename> Settings</title>\r
310                                 <tgroup cols="2">\r
311                                         <colspec colnum="1" colwidth="1.5*"/>\r
312                                         <colspec colnum="2" colwidth="3*"/>\r
313                                         <thead>\r
314                                                 <row>\r
315                                                         <entry>Setting</entry>\r
316                                                         <entry>Explanation</entry>\r
317                                                 </row>\r
318                                         </thead>\r
319                                         <tbody>\r
320                                                 <row>\r
321                                                         <entry condition="pot">&lt;Location /svn&gt;</entry>\r
322                                                         <entry>\r
323                                                                 means that the Git repositories are available from the URL\r
324                                                                 <systemitem class="url">http://MyServer/svn/</systemitem>\r
325                                                         </entry>\r
326                                                 </row>\r
327                                                 <row>\r
328                                                         <entry condition="pot">DAV svn</entry>\r
329                                                         <entry>\r
330                                                                 tells Apache which module will be responsible to serve\r
331                                                                 that URL - in this case the Git module.\r
332                                                         </entry>\r
333                                                 </row>\r
334                                                 <row>\r
335                                                         <entry condition="pot">SVNListParentPath on</entry>\r
336                                                         <entry>\r
337                                                                 For Git version 1.3 and higher, this directive enables\r
338                                                                 listing all the available repositories under\r
339                                                                 <literal>SVNParentPath</literal>.\r
340                                                         </entry>\r
341                                                 </row>\r
342                                                 <row>\r
343                                                         <entry condition="pot">SVNParentPath D:\SVN</entry>\r
344                                                         <entry>\r
345                                                                 tells Git to look for repositories below\r
346                                                                 <filename>D:\SVN</filename>\r
347                                                         </entry>\r
348                                                 </row>\r
349                                                 <row>\r
350                                                         <entry condition="pot">SVNIndexXSLT "/svnindex.xsl"</entry>\r
351                                                         <entry>\r
352                                                                 Used to make the browsing with a web browser\r
353                                                                 prettier.\r
354                                                         </entry>\r
355                                                 </row>                                          \r
356                                                 <row>\r
357                                                         <entry condition="pot">AuthType Basic</entry>\r
358                                                         <entry>\r
359                                                                 is to activate basic authentication, i.e.\r
360                                                                 Username/password\r
361                                                         </entry>\r
362                                                 </row>\r
363                                                 <row>\r
364                                                         <entry condition="pot">AuthName "Git repositories"</entry>\r
365                                                         <entry>\r
366                                                                 is used as an information whenever an authentication\r
367                                                                 dialog pops up to tell the user what the authentication is for\r
368                                                         </entry>\r
369                                                 </row>\r
370                                                 <row>\r
371                                                         <entry condition="pot">AuthUserFile passwd</entry>\r
372                                                         <entry>\r
373                                                                 specifies which password file to use for authentication\r
374                                                         </entry>\r
375                                                 </row>\r
376                                                 <row>\r
377                                                         <entry condition="pot">AuthzSVNAccessFile</entry>\r
378                                                         <entry>\r
379                                                                 Location of the Access file for paths inside a\r
380                                                                 Git repository\r
381                                                         </entry>\r
382                                                 </row>\r
383                                                 <row>\r
384                                                         <entry condition="pot">Require valid-user</entry>\r
385                                                         <entry>\r
386                                                                 specifies that only users who entered a correct\r
387                                                                 username/password are allowed to access the URL\r
388                                                         </entry>\r
389                                                 </row>\r
390                                         </tbody>\r
391                                 </tgroup>\r
392                         </table>\r
393                         But that's just an example. There are many, many more\r
394                         possibilities of what you can do with the Apache web server.\r
395                         <itemizedlist>\r
396                                 <listitem>\r
397                                         <para>\r
398                                                 If you want your repository to have read\r
399                                                 access for everyone but write access only for specific\r
400                                                 users you can change the line\r
401 <screen>\r
402 Require valid-user\r
403 </screen> to\r
404 <screen>\r
405 &lt;LimitExcept GET PROPFIND OPTIONS REPORT&gt;\r
406 Require valid-user\r
407 &lt;/LimitExcept&gt;\r
408 </screen>\r
409                                         </para>\r
410                                 </listitem>\r
411                                 <listitem>\r
412                                         <para>\r
413                                                 Using a <filename>passwd</filename> file limits and \r
414                                                 grants access to all of your repositories as a unit. \r
415                                                 If you want more control over which users have \r
416                                                 access to each folder inside a repository you can \r
417                                                 uncomment the line\r
418 <screen>\r
419 #AuthzSVNAccessFile svnaccessfile\r
420 </screen>\r
421                                                 and create a Git access file. Apache will \r
422                                                 make sure that only valid users are able to access \r
423                                                 your <filename>/svn</filename> location, and will then \r
424                                                 pass the username to Git's <literal>AuthzSVNAccessFile</literal> \r
425                                                 module so that it can enforce more granular access \r
426                                                 based upon rules listed in the Git access file.\r
427                                                 Note that paths are specified either as\r
428                                                 <literal>repos:path</literal> or simply\r
429                                                 <literal>path</literal>. If you don't specify a\r
430                                                 particular repository, that access rule will apply to\r
431                                                 all repositories under\r
432                                                 <literal>SVNParentPath</literal>.\r
433                                                 The format of the authorization-policy file used by\r
434                                                 <literal>mod_authz_svn</literal> is described in\r
435                                                 <xref linkend="tsvn-serversetup-mod_authz_svn"/>\r
436                                         </para>\r
437                                 </listitem>\r
438                                 <listitem>\r
439                                         <para>\r
440                                                 To make browsing the repository with a web browser\r
441                                                 'prettier', uncomment the line\r
442 <screen>\r
443 #SVNIndexXSLT "/svnindex.xsl"\r
444 </screen>\r
445                                                 and put the files <filename>svnindex.xsl</filename>,\r
446                                                 <filename>svnindex.css</filename> and \r
447                                                 <filename>menucheckout.ico</filename> in your document\r
448                                                 root directory (usually <filename>C:/Program Files/Apache Group/Apache2/htdocs</filename>).\r
449                                                 The directory is set with the <literal>DocumentRoot</literal> directive\r
450                                                 in your Apache config file.\r
451                                         </para>\r
452                                         <para>\r
453                                                 You can get those three files directly from our source repository\r
454                                                 at\r
455                                                 <ulink url="http://TortoiseGit.tigris.org/svn/TortoiseGit/trunk/contrib/other/svnindex">\r
456                                                         <citetitle>http://TortoiseGit.tigris.org/svn/TortoiseGit/trunk/contrib/other/svnindex</citetitle>\r
457                                                 </ulink>.\r
458                                                 (<xref linkend="tsvn-preface-source"/> explains how to access the TortoiseGit source repository).\r
459                                         </para>\r
460                                         <para>\r
461                                                 The XSL file from the TortoiseGit repository has a nice\r
462                                                 gimmick: if you browse the repository with your web browser, then\r
463                                                 every folder in your repository has an icon on the right shown.\r
464                                                 If you click on that icon, the TortoiseGit checkout dialog\r
465                                                 is started for this URL.\r
466                                         </para>\r
467                                 </listitem>\r
468                         </itemizedlist>\r
469                 </para>\r
470         </sect2>\r
471         <sect2 id="tsvn-serversetup-apache-parent-path">\r
472                 <title>Multiple Repositories</title>\r
473                 <indexterm>\r
474                         <primary>SVNParentPath</primary>\r
475                 </indexterm>\r
476                 <indexterm>\r
477                         <primary>Index of projects</primary>\r
478                 </indexterm>\r
479                 <para>\r
480                         If you used the <literal>SVNParentPath</literal> directive then you don't have to\r
481                         change the Apache config file every time you add a new Git\r
482                         repository. Simply create the new repository under the same\r
483                         location as the first repository and you're done! In my company\r
484                         I have direct access to that specific folder on the server via\r
485                         SMB (normal windows file access). So I just create a new folder\r
486                         there, run the TortoiseGit command\r
487                         <menuchoice>\r
488                                 <guimenu>TortoiseGit</guimenu>\r
489                                 <guimenuitem>Create repository here...</guimenuitem>\r
490                         </menuchoice>\r
491                         and a new project has a home...\r
492                 </para>\r
493                 <para>\r
494                         If you are using Git 1.3 or later, you can use the\r
495                         <literal>SVNListParentPath on</literal> directive to allow Apache\r
496                         to produce a listing of all available projects if you point your\r
497                         browser at the parent path rather than at a specific repository.\r
498                 </para>\r
499         </sect2>\r
500         <sect2 id="tsvn-serversetup-mod_authz_svn">\r
501                 <title>Path-Based Authorization</title>\r
502                 <indexterm>\r
503                         <primary>Authorization</primary>\r
504                 </indexterm>\r
505                 <indexterm>\r
506                         <primary>mod_authz_svn</primary>\r
507                 </indexterm>\r
508                 <para>\r
509                         The <literal>mod_authz_svn</literal> module permits fine-grained control of access\r
510                         permissions based on user names and repository paths. This is\r
511                         available with the Apache server, and as of Git 1.3\r
512                         it is available with svnserve as well.\r
513                 </para>\r
514                 <para>\r
515                         An example file would look like this:\r
516 <screen>\r
517 [groups]\r
518 admin = john, kate\r
519 devteam1 = john, rachel, sally\r
520 devteam2 = kate, peter, mark\r
521 docs = bob, jane, mike\r
522 training = zak\r
523 # Default access rule for ALL repositories\r
524 # Everyone can read, admins can write, Dan German is excluded.\r
525 [/]\r
526 * = r\r
527 @admin = rw\r
528 dangerman =\r
529 # Allow developers complete access to their project repos\r
530 [proj1:/]\r
531 @devteam1 = rw\r
532 [proj2:/]\r
533 @devteam2 = rw\r
534 [bigproj:/]\r
535 @devteam1 = rw\r
536 @devteam2 = rw\r
537 trevor = rw\r
538 # Give the doc people write access to all the docs folders\r
539 [/trunk/doc]\r
540 @docs = rw\r
541 # Give trainees write access in the training repository only\r
542 [TrainingRepos:/]\r
543 @training = rw\r
544 </screen>\r
545                 </para>\r
546                 <para>\r
547                         Note that checking every path can be an expensive operation,\r
548                         particularly in the case of the revision log. The server\r
549                         checks every changed path in each revision and checks it for\r
550                         readability, which can be time-consuming on revisions which\r
551                         affect large numbers of files.\r
552                 </para>\r
553                 <para>\r
554                         Authentication and authorization are separate processes. If\r
555                         a user wants to gain access to a repository path, she has to meet\r
556                         <emphasis>both</emphasis>, the usual authentication requirements\r
557                         and the authorization requirements of the access file.\r
558                 </para>\r
559         </sect2>\r
560         <sect2 id="tsvn-serversetup-apache-5">\r
561                 <title>Authentication With a Windows Domain</title>\r
562                 <indexterm>\r
563                         <primary>Windows domain</primary>\r
564                 </indexterm>\r
565                 <indexterm>\r
566                         <primary>domaincontroller</primary>\r
567                 </indexterm>\r
568                 <para>\r
569                         As you might have noticed you need to make a username/password\r
570                         entry in the <filename>passwd</filename> file for each user \r
571                         separately. And if (for security reasons) you want your users \r
572                         to periodically change their passwords you have to make the \r
573                         change manually.\r
574                 </para>\r
575                 <para>\r
576                         But there's a solution for that problem - at least if you're\r
577                         accessing the repository from inside a LAN with a windows\r
578                         domain controller: <literal>mod_auth_sspi</literal>!\r
579                 </para>\r
580                 <indexterm>\r
581                         <primary>SSPI</primary>\r
582                 </indexterm>\r
583                 <indexterm>\r
584                         <primary>NTLM</primary>\r
585                 </indexterm>\r
586                 <para>\r
587                         The original SSPI module was offered by Syneapps including\r
588                         source code. But the development for it has been stopped. \r
589                         But don't despair, the community has picked it up and improved\r
590                         it. It has a new home on \r
591                         <ulink url="http://sourceforge.net/projects/mod-auth-sspi/">\r
592                                 <citetitle>SourceForge</citetitle>\r
593                         </ulink>.\r
594                 </para>\r
595                 <itemizedlist>\r
596                         <listitem>\r
597                                 <para>\r
598                                         Download the module which matches your apache version, \r
599                                         then copy the file <filename>mod_auth_sspi.so</filename>\r
600                                         into the Apache modules folder.\r
601                                 </para>\r
602                         </listitem>\r
603                         <listitem>\r
604                                 <para>\r
605                                         Edit the Apache config file: add the line\r
606 <screen>\r
607 LoadModule sspi_auth_module modules/mod_auth_sspi.so\r
608 </screen>\r
609                                         to the <literal>LoadModule</literal> section. Make sure you\r
610                                         insert this line <emphasis>before</emphasis> the line\r
611 <screen>\r
612 LoadModule auth_module modules/mod_auth.so\r
613 </screen>\r
614                                 </para>\r
615                         </listitem>\r
616                         <listitem>\r
617                                 <para>\r
618                                         To make the Git location use this\r
619                                         type of authentication you have to change the line\r
620 <screen>\r
621 AuthType Basic\r
622 </screen>\r
623                                         to\r
624 <screen>\r
625 AuthType SSPI\r
626 </screen>\r
627                                         also you need to add\r
628 <screen>\r
629 SSPIAuth On\r
630 SSPIAuthoritative On\r
631 SSPIDomain &lt;domaincontroller&gt;\r
632 SSPIOmitDomain on\r
633 SSPIUsernameCase lower\r
634 SSPIPerRequestAuth on\r
635 SSPIOfferBasic On\r
636 </screen>\r
637                                         within the <literal>&lt;Location /svn&gt;</literal> block.\r
638                                         If you don't have a domain controller, leave the name of\r
639                                         the domain control as <literal>&lt;domaincontroller&gt;</literal>.\r
640                                 </para>\r
641                         </listitem>\r
642                 </itemizedlist>\r
643                 <para>\r
644                         Note that if you are authenticating using SSPI, then you don't\r
645                         need the <literal>AuthUserFile</literal> line to define a\r
646                         password file any more. Apache authenticates your username and\r
647                         password against your windows domain instead.  You will need to \r
648                         update the users list in your <filename>svnaccessfile</filename> \r
649                         to reference <literal>DOMAIN\username</literal> as well.\r
650 \r
651                 </para>\r
652                 <important>\r
653                         <para>\r
654                                 The SSPI authentication is only enabled for SSL secured\r
655                                 connections (https). If you're only using normal http\r
656                                 connections to your server, it won't work.\r
657                         </para>\r
658                         <para>\r
659                                 To enable SSL on your server, see the chapter:\r
660                                 <xref linkend="tsvn-serversetup-apache-7"/>\r
661                         </para>\r
662                 </important>\r
663                 <tip>\r
664                         <para>\r
665                                 Git <filename>AuthzSVNAccessFile</filename> files are\r
666                                 case sensitive in regard to user names (<literal>JUser</literal>\r
667                                 is different from <literal>juser</literal>). \r
668                         </para>\r
669                         <para>\r
670                                 In Microsoft's world, Windows domains and user names are not\r
671                                 case sensitive.  Even so, some network administrators like \r
672                                 to create user accounts in CamelCase (e.g. <literal>JUser</literal>).\r
673                         </para>\r
674                         <para>\r
675                                 This difference can bite you when using SSPI authentication \r
676                                 as the windows domain and user names are passed to Git \r
677                                 in the same case as the user types them in at the prompt.  \r
678                                 \r
679                                 Internet Explorer often passes the username to Apache \r
680                                 automatically using     whatever case the account was created with.\r
681                         </para>\r
682                         <para>\r
683                                 The end result is that you may need at least two entries in your\r
684                                 <literal>AuthzSVNAccessFile</literal> for each user -- a lowercase entry and an \r
685                                 entry in the same case that Internet Explorer passes to Apache.  \r
686                                 You will also need to train your users to also type in their \r
687                                 credentials     using lower case when accessing repositories via\r
688                                 TortoiseGit.  \r
689                         </para>\r
690                         <para>\r
691                                 Apache's Error and Access logs are your best friend in \r
692                                 deciphering problems such as these as they will help you \r
693                                 determine the username string passed onto Git's \r
694                                 <literal>AuthzSVNAccessFile</literal> module. You may need to\r
695                                 experiment with the exact format of the user string in the\r
696                                 <literal>svnaccessfile</literal>\r
697                                 (e.g. <literal>DOMAIN\user</literal> vs. \r
698                                 <literal>DOMAIN//user</literal>) in order to get \r
699                                 everything working.\r
700                         </para>\r
701                 </tip>\r
702         </sect2>\r
703         <sect2 id="tsvn-serversetup-apache-6">\r
704                 <title>Multiple Authentication Sources</title>\r
705                 <indexterm>\r
706                         <primary>Multiple authentication</primary>\r
707                 </indexterm>\r
708                 <para>\r
709                         It is also possible to have more than one authentication source for\r
710                         your Git repository. To do this, you need to make each \r
711                         authentication type non-authoritative, so that Apache will check\r
712                         multiple sources for a matching username/password.\r
713                 </para>\r
714                 <para>\r
715                         A common scenario is to use both Windows domain authentication and \r
716                         a <literal>passwd</literal> file, so that you can provide SVN access\r
717                         to users who don't have a Windows domain login.\r
718                 </para>\r
719                 <itemizedlist>\r
720                         <listitem>\r
721                                 <para>\r
722                                         To enable both Windows domain and <filename>passwd</filename>\r
723                                         file authentication, add the following entries within the \r
724                                         <literal>&lt;Location&gt;</literal> block of your Apache config file:\r
725 <screen>\r
726 AuthBasicAuthoritative Off\r
727 SSPIAuthoritative Off\r
728 </screen>\r
729                                 </para>\r
730                         </listitem>\r
731                 </itemizedlist>\r
732                 <para>\r
733                         Here is an example of the full Apache configuration for combined Windows \r
734                         domain and <literal>passwd</literal> file authentication:\r
735 <screen>\r
736 &lt;Location /svn&gt;\r
737   DAV svn\r
738   SVNListParentPath on\r
739   SVNParentPath D:\SVN\r
740 \r
741   AuthName "Git repositories"\r
742   AuthzSVNAccessFile svnaccessfile.txt\r
743 \r
744 # NT Domain Logins.\r
745   AuthType SSPI\r
746   SSPIAuth On\r
747   SSPIAuthoritative Off\r
748   SSPIDomain &lt;domaincontroller&gt;\r
749   SSPIOfferBasic On\r
750 \r
751 # Htpasswd Logins.\r
752   AuthType Basic\r
753   AuthBasicAuthoritative Off\r
754   AuthUserFile passwd\r
755 \r
756   Require valid-user\r
757 &lt;/Location&gt;\r
758 </screen>\r
759                 </para>\r
760         </sect2>\r
761         <sect2 id="tsvn-serversetup-apache-7">\r
762                 <title>Securing the server with SSL</title>\r
763                 <indexterm>\r
764                         <primary>SSL</primary>\r
765                 </indexterm>\r
766                 <para>\r
767                         Even though Apache 2.2.x has OpenSSL support, it is not\r
768                         activated by default. You need to activate this manually.\r
769                 </para>\r
770                 <orderedlist>\r
771                         <listitem>\r
772                                 <para>\r
773                                         In the apache config file, uncomment the lines:\r
774 <screen>\r
775 #LoadModule ssl_module modules/mod_ssl.so\r
776 </screen>\r
777                                         and at the bottom\r
778 <screen>\r
779 #Include conf/extra/httpd-ssl.conf\r
780 </screen>\r
781                                         then change the line (on one line)\r
782 <screen>\r
783 SSLMutex "file:C:/Program Files/Apache Software Foundation/\\r
784 Apache2.2/logs/ssl_mutex"\r
785 </screen>\r
786                                         to\r
787 <screen>\r
788 SSLMutex default\r
789 </screen>\r
790                                         \r
791                                 </para>\r
792                         </listitem>\r
793                         <listitem>\r
794                                 <para>\r
795                                         Next you need to create an SSL certificate.\r
796                                         To do that open a command prompt (DOS-Box) and change to\r
797                                         the Apache folder (e.g.\r
798                                         <filename>C:\program files\apache group\apache2</filename>)\r
799                                         and type the following command:\r
800 <screen>\r
801 bin\openssl req -config conf\openssl.cnf -new -out my-server.csr\r
802 </screen>\r
803                                         You will be asked for a passphrase. Please don't use simple\r
804                                         words but whole sentences, e.g. a part of a poem. The\r
805                                         longer the phrase the better. Also you have to enter the\r
806                                         URL of your server. All other questions are optional but we\r
807                                         recommend you fill those in too.\r
808                                 </para>\r
809                                 <para>\r
810                                         Normally the <filename>privkey.pem</filename> file is created\r
811                                         automatically, but if it isn't you need to type this command\r
812                                         to generate it:\r
813 <screen>\r
814 bin\openssl genrsa -out conf\privkey.pem 2048\r
815 </screen>\r
816                                 </para>\r
817                                 <para>\r
818                                         Next type the commands\r
819 <screen>\r
820 bin\openssl rsa -in conf\privkey.pem -out conf\server.key\r
821 </screen>\r
822                                         and (on one line)\r
823 <screen>\r
824 bin\openssl req -new -key conf\server.key -out conf\server.csr \\r
825 -config conf\openssl.cnf\r
826 </screen>\r
827                                         and then (on one line)\r
828 <screen>\r
829 bin\openssl x509 -in conf\server.csr -out conf\server.crt\r
830                  -req -signkey conf\server.key -days 4000\r
831 </screen>\r
832                                         This will create a certificate which will expire in\r
833                                         4000 days. And finally enter (on one line):\r
834 <screen>\r
835 bin\openssl x509 -in conf\server.cert -out conf\server.der.crt\r
836                  -outform DER\r
837 </screen>\r
838                                         These commands created some files in the Apache\r
839                                         <filename>conf</filename> folder \r
840                                         (<filename>server.der.crt</filename>,\r
841                                         <filename>server.csr</filename>,\r
842                                         <filename>server.key</filename>,\r
843                                         <filename>.rnd</filename>,\r
844                                         <filename>privkey.pem</filename>,\r
845                                         <filename>server.cert</filename>).\r
846                                 </para>\r
847                         </listitem>\r
848                         <listitem>\r
849                                 <para>\r
850                                         Restart the Apache service.\r
851                                 </para>\r
852                         </listitem>\r
853                         <listitem>\r
854                                 <para>\r
855                                         Point your browser to\r
856                                         <systemitem class="url">https://servername/svn/project</systemitem>\r
857                                         ...\r
858                                 </para>\r
859                         </listitem>\r
860                 </orderedlist>\r
861                 <important>\r
862                         <title>SSL and Internet Explorer</title>\r
863                         <para>\r
864                                 If you're securing your server with SSL and use authentication\r
865                                 against a windows domain you will encounter that browsing\r
866                                 the repository with the Internet Explorer doesn't work\r
867                                 anymore. Don't worry - this is only the Internet Explorer\r
868                                 not able to authenticate. Other browsers don't have that\r
869                                 problem and TortoiseGit and any other Git client are\r
870                                 still able to authenticate.\r
871                         </para>\r
872                         <para>\r
873                                 If you still want to use IE to browse the repository\r
874                                 you can either:\r
875                                 <itemizedlist>\r
876                                         <listitem>\r
877                                                 <para>\r
878                                                         define a separate <literal>&lt;Location /path&gt;</literal>\r
879                                                         directive in the Apache config file, and add the\r
880                                                         <literal>SSPIBasicPreferred On</literal>.\r
881                                                         This will allow IE to authenticate again, but\r
882                                                         other browsers and Git won't be able to\r
883                                                         authenticate against that location.\r
884                                                 </para>\r
885                                         </listitem>\r
886                                         <listitem>\r
887                                                 <para>\r
888                                                         Offer browsing with unencrypted authentication\r
889                                                         (without SSL) too. Strangely IE doesn't have any\r
890                                                         problems with authenticating if the connection\r
891                                                         is not secured with SSL.\r
892                                                 </para>\r
893                                         </listitem>\r
894                                         <listitem>\r
895                                                 <para>\r
896                                                 In the SSL "standard" setup there's often the \r
897                                                 following statement in Apache's virtual SSL host:\r
898 <screen>\r
899 SetEnvIf User-Agent ".*MSIE.*" \\r
900              nokeepalive ssl-unclean-shutdown \\r
901              downgrade-1.0 force-response-1.0\r
902 </screen>\r
903                                                 There are (were?) good reasons for this configuration, \r
904                                                 see\r
905                                                 <ulink url="http://www.modssl.org/docs/2.8/ssl_faq.html#ToC49">\r
906                                                                 <citetitle>http://www.modssl.org/docs/2.8/ssl_faq.html#ToC49</citetitle>\r
907                                                         </ulink>\r
908                                                 But if you want NTLM authentication you have to use <literal>keepalive</literal>.\r
909                                                 If You uncomment the whole <literal>SetEnvIf</literal> you should be able to\r
910                                                 authenticate IE with windows authentication over SSL against \r
911                                                 the Apache on Win32 with included <literal>mod_auth_sspi</literal>.\r
912                                                 </para>\r
913                                         </listitem>\r
914                                 </itemizedlist>\r
915                         </para>\r
916                 </important>\r
917                 <important>\r
918                         <title>Forcing SSL access</title>\r
919                         <para>\r
920                                 When you've set up SSL to make your repository more secure, you\r
921                                 might want to disable the normal access via non-SSL (http) and\r
922                                 only allow https access.\r
923                                 To do this, you have to add another directive to the Git\r
924                                 <literal>&lt;Location&gt;</literal> block: <literal>SSLRequireSSL</literal>.\r
925                         </para>\r
926                         <para>\r
927                                         An example <literal>&lt;Location&gt;</literal> block would look like this:\r
928 <screen>\r
929 &lt;Location /svn&gt;\r
930   DAV svn\r
931   SVNParentPath D:\SVN\r
932   SSLRequireSSL\r
933   AuthType Basic\r
934   AuthName "Git repositories"\r
935   AuthUserFile passwd\r
936   #AuthzSVNAccessFile svnaccessfile\r
937   Require valid-user\r
938 &lt;/Location&gt;\r
939 </screen>\r
940                         </para>\r
941                 </important>\r
942         </sect2>\r
943         <sect2 id="tsvn-serversetup-apache-sslcerts">\r
944                 <title>Using client certificates with virtual SSL hosts</title>\r
945                 <para>\r
946                         Sent to the TortoiseGit mailing list by Nigel Green. Thanks!\r
947                 </para>\r
948                 <para>\r
949                         In some server configurations you may need to setup a single server\r
950                         containing 2 virtual SSL hosts: The first one for public web access, \r
951                         with no requirement for a client certificate. The second one to be\r
952                         secure with a required client certificate, running a Git server.\r
953                 </para>\r
954                 <para>\r
955                         Adding an <literal>SSLVerifyClient Optional</literal> directive to the \r
956                         <emphasis>per-server</emphasis> section of the Apache configuration\r
957                         (i.e. outside of any <literal>VirtualHost</literal> and\r
958                         <literal>Directory</literal> blocks) forces Apache to request a client\r
959                         Certificate in the initial SSL handshake. Due to a bug in\r
960                         <literal>mod_ssl</literal> it is essential that the certificate is\r
961                         requested at this point as it does not work if the SSL connection\r
962                         is re-negotiated.\r
963                 </para>\r
964                 <para>\r
965                         The solution is to add the following directive to the virtual host\r
966                         directory that you want to lock down for Git:\r
967 <screen>\r
968 SSLRequire %{SSL_CLIENT_VERIFY} eq "SUCCESS"\r
969 </screen>\r
970                         This directive grants access to the directory only if a \r
971                         client certificate was received and verified successfully. \r
972                 </para>\r
973                 <para>\r
974                         To summarise, the relevant lines of the Apache configuration are:\r
975 <screen>\r
976 SSLVerifyClient Optional\r
977 \r
978 ### Virtual host configuration for the PUBLIC host \r
979 ### (not requiring a certificate)\r
980 \r
981 &lt;VirtualHost 127.0.0.1:443&gt;\r
982   &lt;Directory "pathtopublicfileroot"&gt;\r
983   &lt;/Directory&gt;\r
984 &lt;/VirtualHost&gt;\r
985 \r
986 ### Virtual host configuration for Git \r
987 ### (requiring a client certificate)\r
988 &lt;VirtualHost 127.0.0.1:443&gt;\r
989   &lt;Directory "Git host root path"&gt;\r
990     SSLRequire %{SSL_CLIENT_VERIFY} eq "SUCCESS"\r
991   &lt;/Directory&gt;\r
992 \r
993   &lt;Location /svn&gt;\r
994     DAV svn\r
995     SVNParentPath /pathtorepository\r
996   &lt;/Location&gt;\r
997 &lt;/VirtualHost&gt;\r
998 </screen>\r
999                 </para>\r
1000         </sect2>\r
1001 </sect1>\r