LDAP Authentication for Subversion on Ubuntu Feisty

I have been busy configuring a new subversion server for HCL. Our environment is 99% Microsoft so there is already an Active Directory structure in place. Subversion is hosted on Ubuntu Feisty (7.04) and I wanted to leverage the AD for authentication into my repository. Luckily, the installation was pretty straight forward.

There are some things to know about our directory. All of the users that will access the repository will get the same read/write permission. All of these users exist in a single OU within the directory. Access to the repository will be allowed over HTTP. I will be using Apache as the web server.

After a simple base install, I only had to install a few additional components. My memory here is a little rusty, so please bear with me…

1
sudo apt-get install libapache2-svn subversion subversion-tools

This should fetch the subversion components and other dependencies. Confirm yes when asked about the Apache installation.

After the installation is complete, you will need to do some configuration in order to enable the subversion components. First test to make sure the components can load.

1
2
3
# cd /etc/apache2/mods-enabled
# sudo ln -s /etc/apache2/mods-available/dav_svn.load
# sudo /etc/init.d/apache2 restart

If you do not see any errors relating to the start of Apache, the subversion components could be loaded and it is time to configure. If you see some errors, step back and find yourself to Google.

In order to configure the components, we must create a config file. I created mine in the terminal again and opened the document in gedit to edit the contents.

1
2
3
# cd /etc/apache2/mods-enabled
# sudo touch dav_svn.conf
# sudo gedit dav_svn.conf

Here is the contents of the configuration file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Must be turned on to make Apache aware that this is a WEBDAV share run be subversion
DAV svn
 
# Path to my repository location
SVNParentPath /srv/svn/repos
 
# In addition to setting the AuthType, be sure to configure the provider.
AuthType Basic
AuthBasicProvider ldap
AuthName "HCL Subversion Server"
 
# LDAP authentication first binds to the directory and searches for the user specified.  This
# user is used to bind to the directory and perform the search.  Obviously, change the
# DN to a user you have with the correct password.
AuthLDAPBindDN "CN=ldap,OU=Service Accounts,OU=HCL Users,DC=hcl,DC=internal"
AuthLDAPBindPassword ****
 
# This is the most critical part.  This is the URL to the LDAP server specifying the scope
# to search for the user.  See the notes below.
AuthLDAPURL "ldap://gallodc01.hcl.internal:3268/OU=IT,OU=HCL Users,DC=hcl,DC=internal?sAMAccountName"
 
# For some reason this must be set.  Anyone have any ideas?  If it is not set, the entire
# config does not work.  The error logs do not provide much information either.
AuthzLDAPAuthoritative Off
 
require valid-user

There are a few things I want to bring to your attention as I found they related to Active Directory. All of this is in the AuthLDAPURL parameter. First off, you must identify the server that holds the Global Catalog and specify port 3268. The second part is to make sure that sAMAccountName is set as your user identifier. I am not sure is case matters at this point but having worked with Microsoft products long enough, I am just going to match this up with what I found with ADSI Edit.

ADSI Edit??? Yes, that is what I used to interrogate Active Directory to make sure that I was using the proper field. In other LDAP environments, this would be UID or even CN depending upon the LDAP flavor. I would imagine that you could use the standard mail attribute in which case the username would be the email address. That attribute seems constant among all directories I have seen.

Before you restart Apache one last time, create the repo directories, create a repository, and fix the permissions for web access.

1
2
3
4
5
# sudo mkdir -p /srv/svn/repos
# cd /srv/svn/repos
# sudo svnadmin create test
# sudo chown -r www-data:www-data test
# sudo /etc/init.d/apache2 restart

Hopefully you received no errors. Only thing left is to checkout your test project to make sure everything works correctly.

1
2
# cd ~
# svn co --username {AD Username} http://localhost/repos/test

19 thoughts on “LDAP Authentication for Subversion on Ubuntu Feisty

  1. Arrgh!!!!

    I’ve been having trouble for days now! Everyone insists AuthzLDAPAuthoritative should be On. Idiots. :-)

    Thanks, it works beautifully.

  2. On my Ubuntu 7.04 apache-22.0.55-4ubuntu4 subversion 1.4.3dfsg1-1ubuntu1, these two links needed:

    $ sudo ln -s /etc/apache2/mods-available/ldap.load /etc/apache2/mods-enabled/

    $ sudo ln -s /etc/apache2/mods-available/authnz_ldap.load /etc/apache2/mods-enabled/

  3. About the require valid-user directive and AuthzLDAPAuthoritative, this was a real pain for me aswell. The documentation (http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html) states that require valid-user “requires that mod_authz_user be loaded and that the AuthzLDAPAuthoritative directive be set to off.” Notice the last part of the last sentence. I’m not sure why that is, but my guess is that Apache needs to authorize the user after he/she has been authenticated through LDAP. Another option is to use require ldap-user which does not require you to set AuthzLDAPAuthoritative to off.

  4. Pingback: randomnoise» Blog Archive » Ubuntu server setup: LAMP+LDAP+SVN+Trac+MoinMoin

  5. From the mod_authnz_ldap man page:

    “Other Require values may also be used which may require loading additional authorization modules. Note that if you use a Require value from another authorization module [eg require valid-user], you will need to ensure that AuthzLDAPAuthoritative is set to off to allow the authorization phase to fall back to the module providing the alternate Require value.”

    So if you dont have to set AuthzLDAPAuthoritative! It’s only needed because you use “require valid-user”

  6. Thanks, You help me a lot. All good only to say:

    1-the chowm parameter is -R
    2-I used another LDAPURL i think this depend on how you make your schema on ldap.
    3-you can make your repository where you want, but you have to give permissions to www-data (apache user)
    4- Great template design for the blog
    5-thanks thanks and more thanks :D

  7. The only problem I see with all of this is the ldap:// URL Doesn’t that mean that you are sending AD usernames and passwords over the network in plain text? And ldaps:// would be secure (assuming AD is configured properly)?

  8. Just as an FYI:

    Instead of creating the module links by hand, you can use a2enmod:

    sudo a2enmod dav_svn

    will automatically create the appropriate *.load and *.conf links into mods-enabled

    a2ensite does the same thing with sites-available, and a2dismod and a2dissite will turn them off.

  9. Pingback: Confluence: Subversion

  10. Pingback: A successful story after a long try | Micro Thoughts

  11. Pingback: configuring SVN with Ldap

  12. how can i give use the ldap authentication repository wise.

    I want to create a setup so that the user exists in the Ldap and the provided the permission for a specific repository only will view the repository data, otherwise it shouldn’t allow the user to view it. I tried with the below setup but it did not work for me. Any help on this?

    ls /var/svn
    myrepo newrep test testrepo
    are my repositories

    [/]
    * = r

    [newrep:/]
    user1 = r
    user2 = rw

    [test:/]
    user2 = r
    user4 = rw

  13. Above is working fine after i added the above entries in access.txt file in the svn(/var/svn in my case) location and add this to my config file as
    AuthzSVNAccessFile /var/svn/access.txt

  14. I have one(some) more doubt(s):
    previously my svn server is accessible for the clients with the individual passwd settings defined in /svn/repo1/conf/svnserve.conf file. In this passwd-db is the global file which contains the manual entries of user name and passwds and authz is the authentication permissions of individual repositories.
    Now i have set up LDAP with repository wise permissions with AuthzSVNAccessFile (actually ready to set up which was tested in my local machine). How can this effects the previous permissions? shall svn clients from users able to use new passwds which are avilable through my new LDAP config? Can i remove the Entries in the individual repositories of authz and make them in /var/svn/access.txt file?

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">