You are hereBlogs / rahul's blog / CollabNet Subversion - Restricting user access to repositories

CollabNet Subversion - Restricting user access to repositories


rahul's picture

By rahul - Posted on 22 January 2012

I have been using Subversion for version control for a good time now. And I use CollabNet's Subversion server for all in-house SVN repos. It has been only recently that a need arose to restrict access to repositories for my colleagues.

Basically I needed to enable access for a particular repository to a person outside my organization. And I did not want that person to be able to access all other repos (internal to my organization) on the same svn server. Please note that under default settings, all authenticated users have read/write access for all repositories on a CollabNet svn server.

My imagination was I should be able to control the same via svnserve.conf/authz/passwd configuration files specific to each repository. But comments on top of those files (specifically svnserve.conf) made it very clear that these files are only used when accessing via svnserve. If the repo is accessed via http/https, the settings in these configuration files would be ignored.

The next place I looked out was the "Access Rules" section under "Repositories" tab when logged in as admin to CollabNet Subversion Edge GUI. I was decently sure this was the right place for configuring repository based access, but did not quite had a clear idea of the syntax to be used for specifying access rules.

Basic googling and this page in CollabNet's Subversion Community book helped and I was able to quickly muster-up the following access rules that worked exactly how I wanted them to:

 

[/]
admin = rw
rahul.singla = rw

[Repo1:/]
neha.aggarwal = rw

[Repo2:/]

[Repo3:/]
aruna.raheja = rw
neha.aggarwal = rw

[Repo4:/]

[Repo5:/]

[Repo6:/]
yash.kapoor = rw

[Repo7:/]

A detailed explanation of the syntax is available here:
http://www.collab.net/community/subversion/svnbook/svn.serverconfig.pathbasedauthz.html

Basically the section starting with [/] controls access to all repositories. Here I have given the admin user and myself read/write access to all repos.

All sections below control access to a particular repo whose name is inside the brackets. ':/' means the rule is for the root of that repo, you can also control access to particular paths inside a directory. You can also create groups for users and assign access rules for groups that would apply to all users in that group, the exact syntax for the same is available on the above referenced url together with some other handy options for specifying access rules.

You would find this page useful too if you are allowing access via svnserve.

Needless to say, I am loving the way CollabNet's Subversion server works. And the icing on the cake is the above access rules are automatically applied to viewvc also and a user is able to view repo only is s/he has access to the same.

UPDATE:

  • Jan 23, 2012 - A very important point to note is that the casing of repository/paths in your access rules and in your checkout commands should match.
    e.g. if your access rule is like:

    [Repo1:/]
    User1 = rw 

    And User1 tries to check-out:
    https://your-server/svn/repo1

    CollabNet Subversion would give you a unauthorized error. Did you notice the problem: the casing of repository name in your check-out command and in access rule does not match. You will get this error even on Windows where directory/file names are case insensitive.
    A very important gotcha you would want to look out for.

 

Tags

The links you posted are no longer working, do you know where else i can see the articles?

We were scratching our heads as to why revoking read-only access to root was causing issues for our users when commiting to a sub-project. Your article helped clarify the distinction between root and project root. My question, which I linked to your article, was posted on stackoverflow here:

http://stackoverflow.com/questions/15692520/subversion-access-forbidden-cannot-commit-within-tortoise-svn-client-window-wh?noredirect=1#comment22301560_15692520

Thanks again

rahul's picture

Hi Patrick, glad to know this was found useful :)

Hello

i have installed subversion 1.7 with AD authentication works fine , the issue is setting up the folder permission

1. if i dont set [/] in /var/www/svnuser

[/]
* = r

it will show me this error  You don't have permission to access /repo/ on this server.

so i am not able to set the folder accss

 

my subversion config file

<Location /repo>
   DAV svn
 #  SVNPath /svn
   SVNPath /svn/myproject1
   SVNListParentPath on
   AuthzSVNAccessFile   /var/www/svnuser
#   AuthUserFile /var/www/svnauth
      order allow,deny
      allow from all
      Options Indexes
      AuthzLDAPAuthoritative On

      AuthName "My Repository"
      AuthType Basic
      AuthBasicProvider ldap

      AuthLDAPBindDN user@abc.com
      AuthLDAPBindPassword password

      AuthLDAPURL "ldap://abc.com:3268/dc=techmahindra,dc=com?sAMAccoun
tName?sub?(objectCategory=person)"
      Require ldap-group "CN=user,OU=Common ID,OU=Banglore,DC=ABC,DC=
com"

      REQUIRE valid-user


rahul's picture

Please see if this link helps.

Nope stiil the same :)

Post new comment

The content of this field is kept private and will not be shown publicly.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.

Recent comments