Users Online

We have 57 guests online
SVN and ViewVC Notes PDF Print E-mail
Written by Zack MIlls   
Thursday, 17 September 2009 12:43

http://httpd.apache.org/docs/2.2/mod/core.html#location

 

https://help.ubuntu.com/community/Subversion

 

 

 

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 andViewVC settings under the circumstance of Apache HTTP server. It is assumed that you already installed SVN and ViewVC successfully.


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 [1] 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. Note that the URL is case-sensitive if the server is run on the Unix/Linux system. If you type http://micro.stanford.edu/viewvc/repo_a, it may show you "Object not found" error message. (You may want to read webpages, Case Sensitive URLsDan's Web Tips: URLs and How to avoid problems with case-sensitive URL's on UNIX-servers.)

  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
        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
        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
        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
        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 Apache web documents"htpasswd - Manage user files for basic authentication" and "Authentication, Authorization and Access Control".
  5. Restart Apache web server.
    # /usr/sbin/apachectl -k restart
    

There is one more thing to modify. In default, ViewVC is configured to show a Project Root drop-down box in the top right corner of every generated page to allow for quick access to any repository, when a single installation of ViewVC is used to provide access to more than one repository. By deleting lines 30 - 64 of a template file /usr/local/viewvc-1.0.4/templates/include/header.ezt, you can delete the drop-down box so that users who logged-in one repository can not move to other.

Notes

  1. 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 fromhttp://viewvc.tigris.org/source/browse/viewvc/branches/1.0.x/docs/
Last Updated on Thursday, 17 September 2009 13:17