CollabNet
Submerged - CollabNet's Subversion Blog
CollabNet Community

Categories

  • Administration (7)
  • Client Tools (13)
  • downloads (2)
  • General (36)
  • Non-Developers (2)
  • Subversion Client (34)
  • Subversion Events (5)
  • Subversion in the Enterprise (25)
  • Subversion Server (21)
  • Web/Tech (1)

Past 6 Months

  • January 2010 (1)
  • December 2009 (1)
  • November 2009 (3)
  • September 2009 (1)
  • August 2009 (1)
  • July 2009 (2)

Archives

All Archives...
RSS Syndicate this blog

Subversion with Apache and LDAP: Updated

My previous blog entry discussing Subversion, Apache and LDAP is nearing two years old. It was written when Apache 2.0.x was still the mainstream and when Apache 2.2.x was released, changes in the LDAP modules and their respective configuration directives has left my previous entry very confusing for those wanting to use Apache 2.2.x. The purpose of the Definitive Guide is to provide a single location for questions for Apache 2.0.x and 2.2.x, while also providing more depth about things to consider when building your Apache-based Subversion server using LDAP for authentication.

The Configuration

For those of you that just want to get to the point, where you can copy and paste and move on, here you go:

Example Apache 2.2.x Configuration Snippet

# Load Apache LDAP modules
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so

# Load Subversion Apache Modules
LoadModule dav_svn_module     modules/mod_dav_svn.so # Use full path to SUBVERSION_HOME/bin/mod_dav_svn.so on Windows
LoadModule authz_svn_module   modules/mod_authz_svn.so # Use full path to SUBVERSION_HOME/bin/mod_authz_svn.so on Windows

# Work around authz and SVNListParentPath issue
RedirectMatch ^(/repos)$ $1/

# Enable Subversion logging
CustomLog logs/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION

<Location /repos/>
  # Enable Subversion
  DAV svn

  # Directory containing all repository for this path
  SVNParentPath /subversion/svn-repos

  # List repositories colleciton
  SVNListParentPath On

  # Enable WebDAV automatic versioning
  SVNAutoversioning On

  # Repository Display Name
  SVNReposName "Your Subversion Repository"

  # Do basic password authentication in the clear
  AuthType Basic

  # The name of the protected area or "realm"
  AuthName "Your Subversion Repository"

  # Make LDAP the authentication mechanism
  AuthBasicProvider ldap

  # Make LDAP authentication is final
  AuthzLDAPAuthoritative on

  # Active Directory requires an authenticating DN to access records
  AuthLDAPBindDN "CN=ldapuser,CN=Users,DC=your,DC=domain"

  # This is the password for the AuthLDAPBindDN user in Active Directory
  AuthLDAPBindPassword ldappassword

  # The LDAP query URL
  AuthLDAPURL "ldap://your.domain:389/DC=your,DC=domain?sAMAccountName?sub?(objectClass=*)"

  # Require a valid user
  Require valid-user

  # Authorization file
  AuthzSVNAccessFile /subversion/apache2/auth/repos.acl
</Location>

Example Apache 2.0.x Configuration Snippet

# Load Apache LDAP modules
LoadModule ldap_module modules/mod_ldap.so
LoadModule auth_ldap_module modules/mod_auth_ldap.so

# Load Subversion Apache Modules
LoadModule dav_svn_module     modules/mod_dav_svn.so # Use full path to SUBVERSION_HOME/bin/mod_dav_svn.so on Windows
LoadModule authz_svn_module   modules/mod_authz_svn.so # Use full path to SUBVERSION_HOME/bin/mod_authz_svn.so on Windows

# Work around authz and SVNListParentPath issue
RedirectMatch ^(/repos)$ $1/

# Enable Subversion logging
CustomLog logs/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION

<Location /repos/>
  # Enable Subversion
  DAV svn

  # Directory containing all repository for this path
  SVNParentPath /subversion/svn-repos

  # List repositories colleciton
  SVNListParentPath On

  # Enable WebDAV automatic versioning
  SVNAutoversioning On

  # Repository Display Name
  SVNReposName "Your Subversion Repository"

  # LDAP Authentication is final
  AuthLDAPAuthoritative on

  # Do basic password authentication in the clear
  AuthType Basic

  # The name of the protected area or "realm"
  AuthName "Your Subversion Repository"

  # Active Directory requires an authenticating DN to access records
  AuthLDAPBindDN "CN=ldapuser,CN=Users,DC=your,DC=domain"

  # This is the password for the AuthLDAPBindDN user in Active Directory
  AuthLDAPBindPassword ldappassword

  # The LDAP query URL
  AuthLDAPURL "ldap://your.domain:389/DC=your,DC=domain?sAMAccountName?sub?(objectClass=*)"

  # Require authentication
  Require valid-user

  # Authorization file
  AuthzSVNAccessFile /subversion/apache2/auth/repos.acl
</Location>

(The configurations above were for pointing to an Active Directory (AD) server.

Understanding the Configuration

So...the above Apache configurations are what I personally use when building an Apache-based server. Obviously there are changes that need to be made depending on the environment in but for now, it's a great start. To make the best of this opportunity, let's talk about the miscellaneous parts of the configuration.

SVNListParentPath and Subversion's authz

One of the first problems people run into when building an Apache-based Subversion server is when they want to have mod_dav_svn serve a list of repositories. Everything works fine until they enable Subversion's authorization (authz) support. What happens is the server will be configured properly and secured properly but when you go to the repository collection list, which in our case is http://localhost/repos, you are forbidden to view the collection even if you have access. Well, with the RedirectMatch closer to the top of the configuration, you fix this issue. How you might be asking and the reason is that when you enable authz, you must have a trailing slash at the end of the collection url. With the RedirectMatch, we automatically redirect urls to the collection listing when there is no trailing slash. Problem solved.

Custom Subversion Logging

Subversion uses Apache's WebDAV support for providing access to its repositories when using Apache. Unfortunately, when you look at Apache's access logs to try and see your Subversion usage, you end up with a lot of WebDAV communication being logged and you only see a portion of the actual client/server communication. This is because mod_dav_svn uses Apache subrequests and Apache does not log subrequests. Even if it did, turning the Subversion communication in the Apache access log into something meaningful would be nearly impossible. That being said, the configuration above has been setup to use one of Subversion's features: Apache Logging which takes the guess work out.

Subversion Configuration

The other Subversion-specific parts of the Apache configuration are pretty self-explanitory. To summarize what is enabled with the above:

  • SVNListParentPath: Enables the ability to browse the location root and get a list of repositories being served by that url base
  • SVNAutoversioning: Enables the use of WebDAV clients to make changes to the repository contents without using a Subversion client
  • SVNParentPath: Enables serving N number of repositories for the url base
  • SVNReposName: Enables you to put in your own text to be visible in the web browser when browsing your repository contents via the built-in repository browser provided by mod_dav_svn
  • AuthzSVNAccessFile: Tells Subversion's mod_authz_svn module where to find the authz file.

For more details about the Subversion-specific Apache directives, and a list of even more ways you can configure your Apache-based Subversion server, view the mod_dav_svn and the mod_authz_svn documentation.

LDAP Configuration

The LDAP portion of the Apache configuration is where most people run into problems. That being said, we'll spend a little more time explaining the Apache LDAP configuration. The most important thing to note is the subtle differences between Apache 2.0.x and Apache 2.2.x:

Apache 2.0.x           | Apache 2.2.x
-----------------------------------------------
AuthLDAPAuthoritative  | AuthzLDAPAuthoritative
AuthLDAPBindDN         | AuthLDAPBindDN
AuthLDAPBindPassword   | AuthLDAPBindPassword
AuthLDAPURL            | AuthLDAPURL
                       | AuthBasicProvider

You should note that the Apache LDAP module names have also changed between Apache 2.0.x and 2.2.x. Now that we see the naming changes, let's talk about how to properly use these Apache directives to get the LDAP-based authentication you're looking for. (I will be using the Apache 2.2.x names for the Apache directives. If you're still using Apache 2.0.x, please refer to the table above for how to take my documentation and apply it to Apache 2.0.x.)

  • AuthzLDAPAuthoritative: Tells Apache whether or not a failed authentication request can be passed to other Apache modules
  • AuthLDAPBindDN: The distinguished name of the user account that Apache will use to connect to the directory system to perform its user authentication
  • AuthLDAPBindPassword: The password for the user account configured via the AuthLDAPBindDN directive
  • AuthLDAPURL: This is a url that tells where the directory server is, where to look for users at, what user attribute is used to identify a user and other miscellaneous things specific to the LDAP query syntax (More on this later.)
  • AuthBasicProvider: This tells Apache which authentication module you want to use for Basic authentication

All of the directives above are pretty straight forward except for the AuthLDAPURL directive. This directive we will discuss in more detail below. For any other Apache configuration questions, please resort to the Apache Documentation for your respective Apache version.

The LDAP Query URL

For most, the AuthLDAPURL directive is the most challenging to understand. There is good reason for this. That one directive actually consists of 6+ pieces of information that will be different for each Subversion server. Let's break our example AuthLDAPURL into its pieces and discuss the importance, and nuances, of each.

For simplicity, here is the url again, in its entirety: ldap://your.domain:389/DC=your,DC=domain?sAMAccountName?sub?(objectClass=*)

  • Url scheme: [ldap] This is nothing more than a url scheme. It will usually be either 'ldap' or 'ldaps' in the event that you're using SSL for accessing your directory server.
  • Hostname: [your.domain] This is the ip address or hostname of your directory server.
  • Port: [389] This is the port the server is listening on for directory server communication.
  • Search Base: [DC=your,DC=domain] This is the distinguished name to the path in the directory tree that you want to search for users.
  • Username attribute: [sAMAccountName] This is the attribute contains the login name being used.
  • Query scope: [sub] This tells the directory server what type of query to perform.
  • Filter: [(objectClass=*)] This tells the directory server to filter the query for objects matching a particular filter

For more details on constructing an ldap url, which is a standard and not specific to Apache, view RFC 2255.

Working with Active Directory

Active Directory is known as a Multi-Master Directory System. This being said, each directory server in AD does not always have all the necessary information to perform all directory server requests. The best way to handle this is to have Apache query a Global Catalog. A Global Catalog server has the ability to search at the whole forest for users. This means if you want to do domain-wide searches or larger, you need to point to a Global Catalog and you need to update your Apache configuration accordingly. When using a Global Catalog, you should be using port 3268 when performing your queries.

Searching for Users

In the example url above, the sAMAccountName attribute is used to identify the username. This attribute is Windows/Active Directory specific so for those of you using OpenLDAP or another option, that attribute probably will not exist. Change your attribute accordingly. An example is if you wanted to use the Common Name to login, you could specify "CN" as the attribute.

LDAP Query Tuning

The last thing we will talk about is the ability to use filters to make your LDAP query a little more specific. In the example url above we used "(objectClass=*)", which will search for all objects. If you know that you only want to search for a particular object type, like the "user" type, you could use "(objectClass=user)" instead.

Conclusion

Building an Apache-based Subversion server with LDAP as the authentication mechanism can be daunting for some. I hope this has made things easier for you.

ShareThis
Jeremy Whitlock

About the Author

Jeremy Whitlock is a sofware developer in CollabNet's Subversion Engineering team. He is also an open source advocate who contributes to many projects. Jeremy loves playing video games and still continues to be amazed at the personal growth of his three year old son.
Permalink
Categories: Subversion Server

Technorati Tags: apache, ldap, subversion

TrackBack

TrackBack URL for this post: http://www.typepad.com/services/trackback/6a00d834515ac169e2011279138cfc28a4

Comments

Is there a way to refer to LDAP groups in an AuthzSVNAccessFile? - So that groups don't have to be defined in an SVN access control list?

Troels Arvin | March 03, 2009 at 12:21 PM

Troels,
It just so happens there is but it requires using a third-party script, ironically written by me: http://www.thoughtspark.org/node/26. Let me know how it works out for you.

Take care,

Jeremy

Jeremy Whitlock | March 03, 2009 at 12:39 PM

Thanks for this information! It's extremely useful.

Julie | March 03, 2009 at 01:44 PM

If it is going to be the "definitive" guide to this, then it needs to show how to restrict access via LDAP Groups.

Location "/repos/">
# SVN Config and LDAP Authentication Config goes here
LimitExcept GET PROPFIND OPTIONS REPORT>
require ldap-group CN=SubversionUsers,OU=Domain Groups,DC=example,DC=com
/LimitExcept>
/Location>

And now only people in the SubverionUsers can login to the /repos/ repository.

*Note that I due to html rescritions, the angle brackets are incorrect.

Aaron Korver | March 06, 2009 at 01:45 PM

Aaron,
Actually, I've left restricting groups out for another reason. The problem with your approach is that it is blanket restriction, meaning you either have access or you don't based on your group. I have a solution that lets you use LDAP-defined groups in your Subversion authz file which is much, much more granular and flexible. I know for some blanket-level authorization is enough but not for most, which is why I didn't mention it. I guess if you're interested in learning about he solution I speak of, feel free to read the following: http://www.thoughtspark.org/node/26

Take care,

Jeremy

Jeremy Whitlock | March 06, 2009 at 02:32 PM

Does the collabnet subversion package for rhel 5 contains mod_ldap and mod_authnz_ldap modules ?
Or should I compile these modules from sources ?

Thanx for you guide.

--
Fabio

Fabio Canepa | March 07, 2009 at 06:35 AM

Fabio,
From my understanding, they are compiled into the httpd binary. They are available.

Take care,

Jeremy

Jeremy Whitlock | March 07, 2009 at 06:38 PM

Hi Jeremy,

Is there a way to use an encrypted ldap password? It seems a little unsafe to have the ldap password in plain text.

regards,

Jason

Jason Chaffee | March 22, 2009 at 09:44 PM

Jason,
Not that I'm aware. While I can somewhat agree, if you think about it, a server should be locked down anyways. That means that only trusted individuals would have access to the filesystem and its contents, like the Apache configuration file. The suggested thing to do in a case like this is to create a "service" account and lock that account down accordingly. Then, even if someone were to maliciously use the credentials, they'd only have access to a very little piece of information.

Take care,

Jeremy

Jeremy Whitlock | March 23, 2009 at 07:57 AM

I'm having an issue, can't get Apache Service to start when I use the above (top) config for Apache 2.2. Could this be due to incorrect LDAP settings or is there somewhere else I should be looking? I Can't find any clear info in the event logs. I'm a novice with Apache and LDAP but it would help if I knew where I should be looking. Does anyone know if Apache will start ok even if the LDAP configs are wrong (incorrect server or CN, etc.)

When I start Apache 2.2 with a basic httpd.conf it starts up fine:
Location /svn>
DAV svn
SVNParentPath C:\repositories
SVNListParentPath On
Require valid-user
AuthType Basic
AuthName "Subversion repository"
AuthUserFile C:\repositories\password-file
/Location>

Thanks,

Eric Steinberg | April 09, 2009 at 02:08 PM

Also, is the AuthzSVNAccessFile required? If so, is it configured using htpasswd? I thought the reason to use LDAP is to get away from an access file?

Here is the LDAP config that will not allow my Apache 2.2 server to start. I'm wondering if I have AuthLDAPURL configured correctly as this is all internal on my network so I'm referencing the server name:

Location /svn>
# Enable Subversion
DAV svn

# Directory containing all repository for this path
SVNParentPath C:\repositories

# List repositories colleciton
SVNListParentPath On

# Enable WebDAV automatic versioning
SVNAutoversioning On

# Repository Display Name
SVNReposName "Subversion Repository"

# Do basic password authentication in the clear
AuthType Basic

# The name of the protected area or "realm"
AuthName "Subversion Repository"

# Make LDAP the authentication mechanism
AuthBasicProvider ldap

# Make LDAP authentication is final
AuthzLDAPAuthoritative on

# Active Directory requires an authenticating DN to access records
AuthLDAPBindDN "CN=TESTUSER,CN=Users,DC=MY,DC=DOMAIN"

# This is the password for the AuthLDAPBindDN user in Active Directory
AuthLDAPBindPassword TESTPASSWORD

# The LDAP query URL
AuthLDAPURL "ldap://SERVERNAME.my.domain:389/DC=my,DC=domain?sAMAccountName?sub?(objectClass=*)"

# Require a valid user
Require valid-user

# Authorization file
AuthzSVNAccessFile c:\repositories\password-file
/LOCATION>

Eric Steinberg | April 09, 2009 at 02:17 PM

Eric,
Well, the first place to start would be by looking at the Apache error logs. If Apache doesn't start, there is a good chance that it would be in there. If there is nothing in there, you might need to start Apache from the command line to see why it's failing. Sometimes, if the failure is early enough in the startup process, standard out/error is used to relay problems.

As for Apache starting if the LDAP configs are wrong, Apache would still start. It does not validate the actual contents of the LDAP settings. If it's failing to startup, it's probably a syntax problem, unloaded module, failure to load a module or something like that.

Finally, the AuthzSVNAccessFile is used for Subversion's path-based authorization. It has nothing to do with LDAP. LDAP is for authentication while authorization is done using the "authz" mechanism provided by Subversion.

In the end, you need to figure out the cause of the failure. Apache error logs and/or standard out/error would be where to look. Good luck.

Take care,

Jeremy

Jeremy Whitlock | April 09, 2009 at 08:39 PM

hi ,i have a problem that if i want to use two url in the AuthURL,is't possibile?

rok | April 15, 2009 at 12:35 AM

hi ,

I write this is to ask a problem which i have googled but without a result.

My problem is : if i want to authorize a group to have the permission to access an application:subversion, i can use the command below in an auth.conf (saved in folder /etc/httpd/conf.d):
#######

AuthLDAPURL "ldap://localhost/ou=develop,dc=company,dc=com?cn"
require valid-user

#######

and i test it ,the user belong to ou=develop can access subversion .

now i want to give the group testing the same permission as develop.

######
AuthLDAPURL "ldap://localhost/ou=develop,dc=company,dc=com?cn"

AuthLDAPURL "ldap://localhost/ou=testing,dc=company,dc=com?cn"
require valid-user
######

and this doesnot work,only user of develop can access subversion.


then i change it as below :
######
AuthLDAPURL (|("ldap://localhost/ou=develop,dc=company,dc=com?cn")("ldap://localhost/ou=testing,dc=company,dc=com?cn"))
require valid-user
######

when restart apache ,there is the failed message:
----------------------------------------------------------------------------------
Starting httpd: Syntax error on line 44 of /etc/httpd/conf.d/application_auth.conf:
The scheme was not recognised as a valid LDAP URL scheme.
----------------------------------------------------------------------------------

can you tell me how to write two dns in a url ? or other methods to make a couple of groups authorize to a same application?

thank you very much,and any help is appreciative.

rok | April 15, 2009 at 01:34 AM

rok,
Well, you're using the wrong syntax for specifying redundant LDAP servers. The Apache documentation says that you use one AuthLDAPUrl directive and in its value, you separate the redundant LDAP servers with a space. Here is the direct link: http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html#authldapurl Apache's documentation is very in depth and should be consulted anytime you're working with Apache.

Take care,

Jeremy

Jeremy Whitlock | April 15, 2009 at 08:56 AM

If any of you downloaded the sync_ldap_groups_to_svn_authz-*.tar.gz from http://www.thoughtspark.org/node/26 before this comment's post date, you need to update your installation. There was a bug found in versions prior to 1.0.2 that broke the support for nested groups. Please redownload the latest sync_ldap_groups_to_svn_authz-*.tar.gz, which is version 1.0.2 right now.

Jeremy Whitlock | April 15, 2009 at 11:50 AM

hi Jeremy,

i havenot download the sync_ldap_groups_to_svn_authz-*.tar.gz before ,maybe i should try it .i ever thought it's no necessary to install it because my goal is just make users in two groups which in my LDAP server could access subvertion or another directory in Apahce's RootDocument.just access it but not read write or other permissions.

however,i will try it ,and thank you for the helpful advice ,i really should read the Apache's documentation with more care.

rok | April 15, 2009 at 07:28 PM

additional remarks,the two groups are in one LDAP Server ,such as below:
LDAP Server:

company.com
|-----develop
|-----testing
|-----other groups

Apache's RootDocument:
localhost
|---subvertion
|---directory1(folder)
|---directory2(folder)
|---......
|---directoryN(folder)


and my goal is only users in develop and testing (develop+testing,not both in two)could access a directory ,for example the directory is subvertion,the subvertion could be seen just a folder under the Apache's RootDocument.

rok | April 15, 2009 at 07:57 PM

rok,
The tip about the new version of the sync_ldap_groups_to_svn_authz was for the general public, not you. :) I hope you do use it if it has value for you but it was completely unrelated. Sorry if there was any confusion.

Jeremy Whitlock | April 15, 2009 at 11:51 PM

Jeremy,

Ok,I really thank you for the help and maybe I will use your script for a more practical application later. That's was a next stage of my work.

I am sorry to disappoint your hope. Yeah ,thanks for the reply and it's give me a lot of courage to solve my problem, though still in mind air.

rok | April 16, 2009 at 07:07 PM

Hi Jeremy,
I wanted to use Directory groups for SVN Authorization (path based access control) without copying the groups from directory services to AuthzSVNAccessFile. Is that possible?

decafc | April 23, 2009 at 01:09 PM

decafc,
Yes. You can use my Python script here:

http://www.thoughtspark.org/node/26

It is documented, tested and working. Let me know how it treats you.

Take care,

Jeremy

Jeremy Whitlock | April 23, 2009 at 01:16 PM

Thanks for your quick response !
I already went through your website. Your script is copying the group info from Directory service to AuthzSVNAccessFile. But what I am trying to achieve is authorize a person thro Apache directly checking with Directory service to see if that person is part of some group. It is like, I don't want to maintain the group info in AuthzSVNAccessFile, however, I will have the group name and the repo to which this group has access in AuthzSVNAccessFile.

decafc | April 23, 2009 at 02:30 PM

What configuration has to happen on Windows/AD end to allow for LDAP or am I missing something? Confused!

Dave

Dave Hassel | April 24, 2009 at 12:35 PM

Dave,
The configuration above *is* for Active Directory. Are you running into troubles?

Take care,

Jeremy

Jeremy Whitlock | April 24, 2009 at 01:01 PM

I'm new to SVN & LDAP. Doesn't there have be a user/pw that AD knows about? What can I use to test communication from Sun to AD (to list users/groups/etc?)

Dave Hassel | April 24, 2009 at 01:11 PM

Dave,
If you read the blog above, you'll get your answer. In the configuration, which you could just copy/paste/refactor, it has the username/password used to "bind" to the directory server, which in this case is an Active Directory instance. To test, just use any LDAP browsing tool. Google "LDAP Browser" and you see many that are free/open source that you can try right now.

Take care,

Jeremy

Jeremy Whitlock | April 24, 2009 at 01:14 PM

But doesn't the "bind" user need to be in AD & a pw set?

Dave | April 24, 2009 at 01:23 PM

where do I find mod_ldap.so in ColabNet's packages?

Dave | April 27, 2009 at 01:42 PM

The Apache modules are all statically compiled in. So they are there, you just do not see the .so

Mark Phippard | April 29, 2009 at 07:51 AM

Hi Jeremy,
Please answer my question posted above.
I don't want to copy the DS group info to AuthzSVNAccessFile because there are many groups in DS. So, is there a way I can do the authorization directly in DS. Or is there a way, where I can specify the groups which alone needs to be copied to AuthzSVNAccessFile ?

decafc | April 29, 2009 at 12:04 PM

decafc,
Well, Apache let's you use a "Require ldap-group" but it's only blanket level authorization. As for specifying which groups could be brought over, you can create any LDAP query that you need to restrict what constitutes a valid group to bring over via my script. The --help output should give you an idea of what things you can tweak. You can also just point the script at a lower path in the directory as well.

Take care,

Jeremy

Jeremy Whitlock | April 30, 2009 at 09:09 AM

Thanks for the great article. I confirm that it worked almost out-of-the-box with Debian 5 Lenny.
Just as a note, a mistake that could be quite common (at least I did it :P ): don't forget to set repos permissions according to the Apache user. Apache must be able to phisically write in the repo directories or commits won't work.
Thanks again for this guide

Vide | May 05, 2009 at 03:46 AM

Hi. I just installed the most recent copy of CollabNet Subversion on RHEL5 as well as on Solaris 10. I was trying to get the LDAP/AD authentication going but the config errors out saying that it could not find the modules from these lines:

LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so


I ran a find on the system and those files are not found. Do I need to install LDAP separately? Thanks.

BSantos | May 07, 2009 at 10:08 AM

No. For the CollabNet binaries, the ldap modules are built into httpd statically. In that case, you can omit the two LoadModule lines.

Jeremy Whitlock | May 07, 2009 at 10:11 AM

I had to remove the lines for:

# Load Apache LDAP modules
# Load Subversion Apache Modules


I Finally got it working with our AD servers. Thanks again!

BSantos | May 07, 2009 at 12:43 PM

One more thing... Do you happen to know the syntax to rotate the svn logs...

CustomLog logs/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION


Thanks.

BSantos | May 08, 2009 at 05:08 AM

Something odd here. We've got our svn test server on a Fedora 9 box, everything works fine. I setup the production one on Centos 5 and all was fine until we turned on the LDAP auth. I used exactly the same config file from Fedora, made sure all modules were on, etc. and it doesn't work. However, when I sniff the traffic from the Centos -> LDAP server I see coming back:

LDAP searchResDone(3) success

So it appears the LDAP server (OSX openldap) is saying that it's all good, but yet SVN still complains. The only restriction I have is Require valid-user.

Anyone have any idea why CentOS would fail?

Thanks!
Dan

Daniel Wittenberg | May 12, 2009 at 10:24 AM

Hi,

Thanks for the tuto.

But if the LDAP return the error code 773 "User must reset password"

how do you intercept this error ?
how do you manager this error ?

can Apache or Subversion help the user to change the password ?

Thanks

lFora | May 13, 2009 at 12:50 AM

Too bad i didn't have this post 2 years ago when i setup our subversion to authenticate on our eDirectoy tree.


Charles | May 13, 2009 at 08:10 AM

IFora,
Neither Subversion or Apache will assist you in changing your password. I'd hope that the Apache error message would tell you this error occurred but if it doesn't, I'm not sure what you could do other than checking the Apache logs to see why what you think a valid set of login credentials didn't work.

Charles,
I'm glad that it appears to be helpful to you.

Jeremy Whitlock | May 13, 2009 at 08:50 AM

When I login to svn via apache I have to authenticate very often again. That's not usable. How can one stop that? So Apache remembers that I have alreadey authenticated?

Thanks
Heinz

Heinz | June 10, 2009 at 07:43 AM

What are you using to access the repository? If you're using a Subversion client, the client should cache your credentials unless you tell it otherwise. If you're not using a Subversion client, like a web browser, it's really up to the tool to cache credentials. Can you tell more about your setup?

Jeremy Whitlock | June 10, 2009 at 08:09 AM

Using Eclipse 3.3.0 and when clicking on every Plus in the Browser Tree, I am asked for credentials. I can Klick "Save Password", but then it's stored on the disk and i do not want that.

Using tortoisesvn 1.6.2 vor svn checkout, svn commit, svn update I am asked explicitly for credentials again.

Here is my dav_svn.conf:

RedirectMatch ^(/svn)$ $1/
CustomLog logs/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION

DAV svn
SVNParentPath /var/svn
SVNListParentPath On
SVNAutoversioning On
SVNReposName "Subversion Repository"
AuthBasicProvider ldap
AuthzLDAPAuthoritative off
AuthLDAPURL "ldap://ldapserver.domain.tld:9389/ou=People,o=company"
AuthType Basic
AuthName "Subversion Authentication"
Require user xuser yuser zuser

Heinz | June 11, 2009 at 12:50 AM

Eclipse 3.3.0 with Subclipse 1.6.x Plugin

Heinz | June 11, 2009 at 12:53 AM

Client OS: Window$ XP

Server:
Subversion Server 1.4.2
OS Linux

Heinz | June 11, 2009 at 01:19 AM

Heinz,
This is not a server configuration thing. No matter how you have your server configured, it's the Subversion client that dictates credential caching. Subversion by default caches your credentials, encrypted on Windows an OS X, on your filesystem. If you do not want that, you have to explicitly tell your client not to do that. If your Subversion client has cached your credentials and you do not want that, search for the file with the cached credentials in %APPDATA%/Subversion/auth/ based on the url and then delete that file. This is a client-side issue and has nothing to do with your server configuration.

Jeremy Whitlock | June 11, 2009 at 08:52 AM

I have installed usvn on Ubunto, I have an LDAP server and a samba server installed on ubunto too. How can I authenticate the subversion by LDAP?? thanks for helping

freebo | August 19, 2009 at 07:45 AM

Our LDAP has our users authenticating via their "Uid" which is a simple empoloyee number. This causes all of our commit logs to be hard to determine who-did-what. Is there a way to have the svn committer be a different ldap field than the one they use for their svn --username? In our case I'd like to use a concatenation of the user's "givenName" and "sn" fields or, if that's not possible, their "mail" field would suffice.

Eric Smalling | August 21, 2009 at 09:19 AM

Eric,
What I've seen is people using the post-commit hook to handle this. What you can do is use svnlook to get the author of the newly created revision, look it up in LDAP, get the preferred name to display/store in Subversion and then update the svn:author revision property for the newly created revision with the preferred username. Shouldn't be too hard with a little python and python-ldap.

Take care,

Jeremy

Jeremy Whitlock | August 21, 2009 at 02:45 PM

Does anyone have experience with Subversion with Apache and SLAPD? I am trying to encrypt over SSL and am not sure of the correct way to configure LDAP, Subversion and/or HTTPD and SLAPD. Thanks

Patricia Moss | August 24, 2009 at 09:54 AM

I have a test server with the following code in the httpd.conf file.
It's Apache 2.2.9 on Ubuntu Linux.

AuthBasicProvider ldap
AuthType Basic
AuthzLDAPAuthoritative off
AuthName "My Subversion server"
AuthLDAPURL
"ldap://my.server:389/DC=mydepartment,DC=myschool,DC=edu?sAMAccountName?sub?(objectClass=*)" NONE
AuthLDAPBindDN "mylockeddownuser@mydepartment.myschool.edu"
AuthLDAPBindPassword mypassword
require valid-user


Under this setup, everything works fine.

However, if you put in the exact same code in the httpd.conf file on
Windows Server 2008 enterprise with Apache 2.2.11, it does not work.

Any ideas?

Rowland | October 27, 2009 at 12:56 PM

Rowland,
If you could quantify "does not work", that would be helpful. Are you seeing errors in the Apache logs? I'd need more information since in theory, an Apache Location block should work the same on different operating systems assuming the major Apache version is the same, which in your case it is. I'll need more information.

Take care,

Jeremy

Jeremy Whitlock | October 27, 2009 at 01:01 PM

Hi Jeremy.

Thank you for the fast reply. I've tried several different browsers (Firefox, Opera, IE8) with the same results.

When I access the website hosted on the Win2K8 machine, I receive a 500 error:

Server error!

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the webmaster.
Error 500
My IP address
10/27/09 15:31:49
Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9

The Apache log lists:

Content-language: en
Content-type: text/html; charset=ISO-8859-1
Body:----------en--


This server could not verify that you are authorized to access
the URL "".
You either supplied the wrong credentials (e.g., bad password), or your
browser doesn't understand how to supply the credentials required.

In case you are allowed to request the document, please
check your user-id and password and try again.

Thank you again for your help.

Rowland | October 27, 2009 at 01:34 PM

Why don't we take this to a forum so you can paste your configuration. (http://subversion.open.collab.net/ds/viewForumSummary.do?dsForumId=3)

Jeremy Whitlock | October 27, 2009 at 03:08 PM

Hi apache 2.2.* configuration file have some problem.

"AuthLDAPAuthoritative on" have to be change like "AuthzLDAPAuthoritative on".

Other than great tutorial, worked for me.

Thanks..
Regards..

Yasith Tharindu | January 16, 2010 at 08:40 AM

I got this to work with two important changes:

Create a file called /subversion/apache2/auth/repos.acl with contents:

[/]
* = rw

Change

AuthLDAPBindDN "CN=ldapuser,CN=Users,DC=your,DC=domain"

to

AuthLDAPBindDN "username@your.domain"

louiechristiehub | January 25, 2010 at 10:49 AM

Hello,

I have set up the SVN server using Apache (LDAP+SSL). When i try to login through the Tortoise SVN client i face issues in logging in with the following error in logs "auth_ldap authenticate: user abc authentication failed; URI /test [ldap_search_ext_s() for user failed][Operations Error]"
Wen i restart my machine i am able to login successfully.

Apache(httpd.conf) configuration below.
##################
#Subversion configuration - Enable LDAP

DAV svn
SVNPath C:/svnroot/test
#Do basic password authentication in the clear
AuthType Basic
AuthName "Subversion Repository"
#Make LDAP the authentication mechanism
AuthBasicProvider "ldap"
#Options FollowSymLinks
Order allow,deny
Allow from all
#The LDAP query URL
AuthLDAPURL "ldap://server.example.com:389/DC=example,DC=com?sAMAccountName?sub?(objectClass=user)"
#Make LDAP authentication is final
AuthzLDAPAuthoritative off
#Active Directory requires an authenticating DN to access records
AuthLDAPBindDN "abc@example.com"
#This is the password for the AuthLDAPBindDN user in Active Directory
AuthLDAPBindPassword "mypasswd123"
AuthzSVNAccessFile C:/etc/svn-acl_intel
Require valid-user

##################

Secondly, I do not want to keep the password "AuthLDAPBindPassword "mypasswd123" ". Is there a way where I can take the password as input?

Please let me know if there is any solution to the above problem.

Thanks
-Megha

megha | February 08, 2010 at 04:05 AM

Megha,
If things work after a reboot, that leads me to believe that you didn't restart Apache after you made changes to your Apache configuration and the reboot basically restarted Apache. As for storing the AuthLDAPBindPassword in clear text within httpd.conf, there is no other option. Since servers are usually secured properly, most don't have to worry about the password being in clear text. But if you want another level of security, just create a "service account" user and have that user in your configuration.

Take care,

Jeremy

Jeremy Whitlock | February 08, 2010 at 07:42 AM

Post a comment

If you have a TypeKey or TypePad account, please Sign In

You are currently signed in as (nobody). Sign Out

  • ©2010 CollabNet Corporation
    • Site Feedback
    • Terms of Use
    • Privacy Policy
    • Copyright & Trademark