Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Apache2 LDAP authorization for Subversion with OpenDS

rajeshkumar created the topic: Apache2 LDAP authorization for Subversion with OpenDS
Apache2 LDAP authorization for Subversion with OpenDS

There are several ways to enable user authentication for web based applications, like .htaccess files, plain tekst files, databases, LDAP, etc. They all have their pros and cons. In case a central, flexible solution is needed, either a database or LDAP solution can be used.

I chose for an LDAP solution since it can be reused by many web and application servers and the applications that run on them while many LDAP solutions provide excellent tooling and easy configuration. Since Yenlo strongly focuses on GlassFish and other Sun tools, I chose OpenDS to authenticate against.The idea is to create a bunch of users and put them into one or more groups. Each group gets access to one specific Subversion repository and every user that needs access to a certain subversion repositoy needs to be in the corresponding group.

This blog describes the basic steps I took to get Basic HTTP authentication for Subversion using Apache2 and OpenDS.
Setting up the server

The server is running on Debian Etch, for which most of the required software is available via the Debian package repository. The packages I installed are
apache2
apache2-mpm-prefork
libapache2-svn
subversion
sun-java6-bin
sun-java6-jdk
sun-java6-jre

Apart form these packages I downloaded and installed the OpenDS 2.2 zip file from the OpenDS homepage. For this purpose I created a user and a group called “opends” and the directory /usr/local/opends which I gave both ownership and group “opends”. Next I logged in as user opends and extracted the zip file into that directory. Finally, as root, I created a start and stop script and used the update-rc.d script to make sure OpenDS is automatically started and stopped when the server is started and stopped.

Setting up Subversion

Let’s suppose that our organisation has decided to create a Subversion repository for each development project that we do. This means that we would get a directory structure like this, with the leaves being the root directories of each repository:
/usr/share/subversion
/repository1
/repository2

The repositories were created as root using these commands in the /usr/share/subversion directory
# svnadmin create repository1
# svnadmin create repository2

That’s all the configuration that was done to the Subversion repositories.

Configuring OpenDS

First, a basic setup of OpenDS needed to be done using the command
$ /usr/local/opends/OpenDS-2.2.0/bin/setup

For more info about this, see Setting Up the Directory Server. Please note that if you are not running OpenDS as root user, it will listen on port 1389.

The next step was to configure OpenDS so it contains a few users and groups. The main configuration tool for OpenDS is called control-panel and, in my case, it can be started as user “opends” by issuing this command:
$ /usr/local/opends/OpenDS-2.2.0/bin/control-panel

With this tool, among other things, you can manage the entries in the directory. For my purpose I created the next layout
base dn (dc=yenlo,dc=nl)
organisation (o=yenlo)
organisational unit (ou=devel)
user (uid=wouter1, password = wouter1)
user (uid=wouter2, password = wouter2)
user (uid=wouter3, password = wouter3)
group (cn=group1, uniqueMember=wouter1,wouter2)
group (cn=group2, uniqueMember=wouter2,wouter3)

which is a very simple layout but sufficient for now. Note that I created two Subversion repositories and therefore two LDAP groups, one for each Subversion repository.

Setting up Apache2 to get access to the Subversion repositories

First I configured Apache2 so the two repositories were accessible to anyone using e.g. a web browser. After libapache2-svn is installed, the module should be enabled in the Apache2 configuration files automatically. To verify this, check the
/etc/apache2/mods-enabled/

directory and make sure these symbolic links exist
dav.load -> ../mods-available/dav.load
dav_svn.conf -> ../mods-available/dav_svn.conf
dav_svn.load -> ../mods-available/dav_svn.load

If the first link is missing, create it as root using
# a2enmod dav

If the second and third are missing, create it as root using
# a2enmod dav_svn

To make sure the modules are loaded by Apache2, restart the server as root using
# /etc/init.d/apache2 restart

Now some modifications need to be made to the dav_svn configuration file
/etc/apache2/mods-available/dav_svn.conf

The idea is that there are two Subversion repositories that need to be configured individually. So, these two entries need to be put in the above mentioned configuration file

DAV svn
SVNPath /usr/share/subversion/repository1
SVNListParentPath On
SVNAutoversioning On
SVNReposName “Repository1 Subversion Repository”


DAV svn
SVNPath /usr/share/subversion/repository2
SVNListParentPath On
SVNAutoversioning On
SVNReposName “Repository2 Subversion Repository”

Now, if you point your browser to either http:///svn/repository1 or http:///svn/repository2 you should see the root of your repository.

Adding LDAP support using OpenDS

In order to use LDAP atuentication with Apache2, these two entries should be present in /etc/apache2/mods-enabled:
authnz_ldap.load -> ../mods-available/authnz_ldap.load
ldap.load -> ../mods-available/ldap.load

If they aren’t present, you can enable them as root with these commands
# a2enmod authnz_ldap
# a2enmod ldap
# /etc/init.d/apache2 restart

Now, each entry in /etc/apache2/mods-available/dav_svn.conf should be extended with these lines in order to get LDAP authentication working with OpenDS. Please note that you should pay attention to the group you assign to each subversion repository location. I am only showing the configuration addition for repository1 and leave it as an excercise to you to setup the second repository configuration. Also please note you make sure the correct password for the Directory Manager is provided. For more info about these configuration settings, please consult the OpenDS WIKI page on Apache Web Server.
AuthType Basic
AuthName “Repository1 Subversion Repository”
AuthBasicProvider ldap
AuthzLDAPAuthoritative off
AuthLDAPURL ldap://localhost:1389/dc=yenlo,dc=nl?uid
AuthLDAPBindDN “cn=Directory Manager”
AuthLDAPBindPassword mypassword
AuthLDAPGroupAttribute uniqueMember
AuthLDAPGroupAttributeIsDN on
Require ldap-group cn=repository1,ou=devel,o=yenlo,dc=yenlo,dc=nl

Issue a final
# /etc/init.d/apache2 restart

and you should be prompted for a username and password when you try to access either repository. Using the correct uid and password combination should grant you access to the repository.

Next stepts

The authentication mechanism we chose, Basic autentication, posts usernames and passwords in plain text, which potentially could be harmful in case someone sniffes the connection. I would strongly recommend to setup SSL based connections. Moreover, this blog post only shows how to secure one repository layout using LDAP. Both Subversion and Apache are sufficiently flexible that other layouts are possible. Those layouts most likely require tweaking of the Apache2 configuration options. Finally, I am not an LDAP expert so the directory structure I chose in OpenDS most likely can be much improved. However, following the steps in this article should get you on your way to using OpenDS incombination with Apache2.

Reference: Referencehttp://www.yenlo.nl/woutervanreeven/2010/03/15/apache2-ldap-authorization-for-subversion-with-opends/
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: Re:Apache2 LDAP authorization for Subversion with Opends
Subversion authorization through LDAP with OpenDS

If you building a centralized development environment for a team or large group of users, the question of centralizing user identities, authentication and authorization is always popping up and the answer is often to use an LDAP directory server. The developer section of the OpenDS documentation wiki has a set of tutorials for using the OpenDS LDAP directory server with various web servers and open source project like GlassFish, Apache Tomcat, SugarCRM… But not yet for Subversion. Thankfully, Wooter van Reeven, Senior Consultant at Yenlo has just published a long and detailed tutorial for setting up Subversion authentication and authorization through LDAP, with OpenDS and Apache2.

blogs.sun.com/Ludo/entry/subversion_auth…on_through_ldap_with
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Rajesh Kumar
Follow me
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x