Micro and Nano Mechanics Group
(Difference between revisions)

Revision as of 13:18, 19 January 2008

Let's assume that we want to create more than one Subversion (SVN) repository and SVN users may or may not access to each repository depending on their authorization. This webpage will explain how to configure Subversion and ViewVC settings under the circumstance of Apache HTTP server.


For simplicity, let's say we have two repositories REPO_A and REPO_B. Now we start to edit couple of things in the ViewVC configuration file, viewvc.conf

  1. Specify svn_roots, which says the absolute path to each repository and assigns a name, such as
    svn_roots = REPO_A: /PATH/TO/REPO_A,
                REPO_B: /PATH/TO/REPO_B
    

    Here /PATH/TO/REPO_A and /PATH/TO/REPO_B should be replaced appropriately according as where each repository is located in your system. The repository name and the directory name of the repository do not need to be same.

  2. Comment out root_parents.
  3. Activate root_as_url_component, which interpretes the first path component <ref>To know what is the first path component in the URL after the script location, refer ViewVC 1.1 URL Reference. You can download url-reference.html from http://viewvc.tigris.org/source/browse/viewvc/branches/1.0.x/docs/</ref> in the URL after the script location as the root to use.
    root_as_url_component = 1     
    

    By activating this option, the website URL becomes natural. What it means by "natural" is, for example, I can view the REPO_A by typing http://micro.stanford.edu/ViewVC/REPO_A in the web browser. Otherwise, it would be like http://micro.stanford.edu/ViewVC/?root=REPO_A.

  4. Specify docroot, a web path to a directory that contains ViewVC static files (stylesheets, images, etc.).
    docroot = /viewvc/docroot
    

    Make sure that this is a (alias) web path which is defined in the HTTP configuration file, httpd.conf.

In httpd.conf, you also have a few things to change.

  1. Define an alias docroot and its absolute path, which will be used in viewvc.conf, by inserting
    Alias /viewvc/docroot /usr/local/viewvc-1.0.4/templates/docroot
    

    inside of the alias module <IfModule alias_module> ... </IfModule>. Then you have to provide a <Directory> section to allow access to the filesystem path.

    <Directory /usr/local/viewvc-1.0.4/templates/docroot>
        Order allow,deny
        Allow from all
    </Directory>
    
  2. Use ScriptAlias directive to map a URL to viewvc.cgi script which is not in the DocumentRoot directory.
    ScriptAlias /viewvc/REPO_A "/usr/local/viewvc-1.0.4/bin/cgi/viewvc.cgi/REPO_A"
    ScriptAlias /viewvc/REPO_B "/usr/local/viewvc-1.0.4/bin/cgi/viewvc.cgi/REPO_B"
    

    inside of the alias module <IfModule alias_module> ... </IfModule>. Again, you need to allow the access to the script directory.

    <Directory /usr/local/viewvc-1.0.4/bin/cgi>
        Order allow,deny
        Allow from all
    </Directory>
    

    Typing URL such as http://micro.stanford.edu/viewvc/REPO_A runs internally viewvc.cgi and opens the repo REPO_A in the browser. If you prefer lowercase URL, you may add the following line additionally.

    ScriptAlias /viewvc/repo_a "/usr/local/viewvc-1.0.4/bin/cgi/viewvc.cgi/REPO_A"
    

    Then you can access the same site by typing http://micro.stanford.edu/viewvc/repo_a.

  3. Use <Location> directives for each repository to set up different authorization.
    <Location /svn/REPO_A>
        DAV svn
        SVNPath /PATH/TO/REPO_A
        AuthType Basic
        AuthName "SVN for REPO_A"
        AuthBasicProvider file
        AuthUserFile  /PATH/TO/PASSWORD/FILE
        AuthGroupFile /PATH/TO/GROUP/FILE
        SSLRequireSSL 
        Require group REPO_A ADMIN
    </Location>
    
    <Location /svn/REPO_B>
        DAV svn 
        SVNPath /PATH/TO/REPO_B
        AuthType Basic
        AuthName "SVN for REPO_B"
        AuthBasicProvider file
        AuthUserFile  /PATH/TO/PASSWORD/FILE
        AuthGroupFile /PATH/TO/GROUP/FILE
        SSLRequireSSL
        Require group REPO_B ADMIN
    </Location>
    
    <Location /viewvc/REPO_A>
        AuthName "Subversion repository A with ViewVC"
        AuthType Basic
        AuthUserFile  /PATH/TO/PASSWORD/FILE
        AuthGroupFile /PATH/TO/GROUP/FILE
        SSLRequireSSL
        Require group REPO_A ADMIN
    </Location>
    
    <Location /viewvc/REPO_B>
        AuthName "Subversion repository B with ViewVC"
        AuthType Basic
        AuthUserFile  /PATH/TO/PASSWORD/FILE
        AuthGroupFile /PATH/TO/GROUP/FILE
        SSLRequireSSL
        Require group REPO_B ADMIN
    </Location>
    

    Each directive checks the same password and group files, and the user access is allowed only if the user belongs to the valid groups. In the above example, there are three groups: REPO_A, REPO_B and ADMIN. Users of group REPO_A can access only to the repository REPO_A while those of REPO_B can only to the repository REPO_B. Users who belong to ADMIN group can access to both repositories.

  4. For those who don't know how to use htpasswd to create a password file, refer this.

There is one more thing to modify.

Notes

<references/>