Search code examples
svndebiansvnadmin

svnadmin add new user and assign it only one repo


I will create a new user on my svn server, which can access only in one of my repository. It's possible?

My server runs debian squeeze.


Solution

  • You can set permissions using svn authz file. First of all, we need to create an Access Control file.

    sudo nano /etc/apache2/svn_access_control
    

    User Groups

    You can create groups of users and then use those for rules. You do this under a special heading in square brackets:

    [groups]
    mygroup = dave, mike
    

    This will create a group called ‘mygroup’ which ‘dave’ and ‘mike’ belongs to.

    And now for some examples. Examples

    [groups]
    team = bob, bill devteam = bob, barry, brett
    [/]
    @team = r bob = rw
    [/wowapp/trunk]
    @team = r @devteam = rw brenda = rw
    

    In this example:

    Created a group team which has two members; bob and bill.
    Created another group, called devteam which has three members; bob, barry, brett.
    In the root of the repository, I’ve given the group team read permissions.
    Also, in the root, bob has read and write permissions.
    In the trunk of wowapp, the group team has read permission.
    Also, the devteam group has read and write permissions.
    And another user, called brenda has read and write permissions.
    

    You need to add is the following line in apache svn configuration file.

    AuthzSVNAccessFile /etc/apache2/svn_access_control
    

    So that the file looks like this:

    <Location /svn>
      DAV svn
      SVNPath /home/svn
    
      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /etc/apache2/dav_svn.passwd
    
      AuthzSVNAccessFile /etc/apache2/svn_access_control
    
      Require valid-user
    </Location>
    

    Save the file, and then restart Apache2:

    sudo /etc/init.d/apache2 restart
    

    You should now have access control working for Subversion over Apache2.