{"id":1789,"date":"2017-12-06T06:34:27","date_gmt":"2017-12-06T06:34:27","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=1789"},"modified":"2020-01-09T09:40:50","modified_gmt":"2020-01-09T09:40:50","slug":"apache2-ldap-authorization-for-subversion-with-opends","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/apache2-ldap-authorization-for-subversion-with-opends\/","title":{"rendered":"Apache2 LDAP authorization for Subversion with OpenDS"},"content":{"rendered":"<p><strong>rajeshkumar created the topic: Apache2 LDAP authorization for Subversion with OpenDS<\/strong><br \/>\nApache2 LDAP authorization for Subversion with OpenDS<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>This blog describes the basic steps I took to get Basic HTTP authentication for Subversion using Apache2 and OpenDS.<br \/>\nSetting up the server<\/p>\n<p>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<br \/>\napache2<br \/>\napache2-mpm-prefork<br \/>\nlibapache2-svn<br \/>\nsubversion<br \/>\nsun-java6-bin<br \/>\nsun-java6-jdk<br \/>\nsun-java6-jre<\/p>\n<p>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 \u201copends\u201d and the directory \/usr\/local\/opends which I gave both ownership and group \u201copends\u201d. 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.<\/p>\n<p>Setting up Subversion<\/p>\n<p>Let\u2019s 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:<br \/>\n\/usr\/share\/subversion<br \/>\n                     \/repository1<br \/>\n                     \/repository2<\/p>\n<p>The repositories were created as root using these commands in the \/usr\/share\/subversion directory<br \/>\n# svnadmin create repository1<br \/>\n# svnadmin create repository2<\/p>\n<p>That\u2019s all the configuration that was done to the Subversion repositories.<\/p>\n<p>Configuring OpenDS<\/p>\n<p>First, a basic setup of OpenDS needed to be done using the command<br \/>\n$ \/usr\/local\/opends\/OpenDS-2.2.0\/bin\/setup<\/p>\n<p>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.<\/p>\n<p>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 \u201copends\u201d by issuing this command:<br \/>\n$ \/usr\/local\/opends\/OpenDS-2.2.0\/bin\/control-panel<\/p>\n<p>With this tool, among other things, you can manage the entries in the directory. For my purpose I created the next layout<br \/>\nbase dn (dc=yenlo,dc=nl)<br \/>\n  organisation (o=yenlo)<br \/>\n    organisational unit (ou=devel)<br \/>\n      user (uid=wouter1, password = wouter1)<br \/>\n      user (uid=wouter2, password = wouter2)<br \/>\n      user (uid=wouter3, password = wouter3)<br \/>\n      group (cn=group1, uniqueMember=wouter1,wouter2)<br \/>\n      group (cn=group2, uniqueMember=wouter2,wouter3)<\/p>\n<p>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.<\/p>\n<p>Setting up Apache2 to get access to the Subversion repositories<\/p>\n<p>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<br \/>\n\/etc\/apache2\/mods-enabled\/<\/p>\n<p>directory and make sure these symbolic links exist<br \/>\ndav.load -> ..\/mods-available\/dav.load<br \/>\ndav_svn.conf -> ..\/mods-available\/dav_svn.conf<br \/>\ndav_svn.load -> ..\/mods-available\/dav_svn.load<\/p>\n<p>If the first link is missing, create it as root using<br \/>\n# a2enmod dav<\/p>\n<p>If the second and third are missing, create it as root using<br \/>\n# a2enmod dav_svn<\/p>\n<p>To make sure the modules are loaded by Apache2, restart the server as root using<br \/>\n# \/etc\/init.d\/apache2 restart<\/p>\n<p>Now some modifications need to be made to the dav_svn configuration file<br \/>\n\/etc\/apache2\/mods-available\/dav_svn.conf<\/p>\n<p>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<br \/>\n<Location \/svn\/repository1><br \/>\nDAV svn<br \/>\nSVNPath \/usr\/share\/subversion\/repository1<br \/>\nSVNListParentPath On<br \/>\nSVNAutoversioning On<br \/>\nSVNReposName \u201cRepository1 Subversion Repository\u201d<br \/>\n<\/Location><br \/>\n<Location \/svn\/repository2><br \/>\nDAV svn<br \/>\nSVNPath \/usr\/share\/subversion\/repository2<br \/>\nSVNListParentPath On<br \/>\nSVNAutoversioning On<br \/>\nSVNReposName \u201cRepository2 Subversion Repository\u201d<br \/>\n<\/Location><br \/>\nNow, if you point your browser to either http:\/\/<host>\/svn\/repository1 or http:\/\/<host>\/svn\/repository2 you should see the root of your repository.<\/p>\n<p>Adding LDAP support using OpenDS<\/p>\n<p>In order to use LDAP atuentication with Apache2, these two entries should be present in \/etc\/apache2\/mods-enabled:<br \/>\nauthnz_ldap.load -> ..\/mods-available\/authnz_ldap.load<br \/>\nldap.load -> ..\/mods-available\/ldap.load<\/p>\n<p>If they aren\u2019t present, you can enable them as root with these commands<br \/>\n# a2enmod authnz_ldap<br \/>\n# a2enmod ldap<br \/>\n# \/etc\/init.d\/apache2 restart<\/p>\n<p>Now, each <Location> 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.<br \/>\nAuthType Basic<br \/>\nAuthName \u201cRepository1 Subversion Repository\u201d<br \/>\nAuthBasicProvider ldap<br \/>\nAuthzLDAPAuthoritative off<br \/>\nAuthLDAPURL ldap:\/\/localhost:1389\/dc=yenlo,dc=nl?uid<br \/>\nAuthLDAPBindDN \u201ccn=Directory Manager\u201d<br \/>\nAuthLDAPBindPassword mypassword<br \/>\nAuthLDAPGroupAttribute uniqueMember<br \/>\nAuthLDAPGroupAttributeIsDN on<br \/>\nRequire ldap-group cn=repository1,ou=devel,o=yenlo,dc=yenlo,dc=nl<\/p>\n<p>Issue a final<br \/>\n# \/etc\/init.d\/apache2 restart<\/p>\n<p>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.<\/p>\n<p>Next stepts<\/p>\n<p>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.<\/p>\n<p>Reference: Reference<a href=\"http:\/\/www.yenlo.nl\/woutervanreeven\/2010\/03\/15\/apache2-ldap-authorization-for-subversion-with-opends\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.yenlo.nl\/woutervanreeven\/2010\/03\/15\/apache2-ldap-authorization-for-subversion-with-opends\/<\/a><br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n<p><strong>rajeshkumar replied the topic: Re:Apache2 LDAP authorization for Subversion with Opends<\/strong><br \/>\nSubversion authorization through LDAP with OpenDS<\/p>\n<p>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&#8230; 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.<\/p>\n<p>blogs.sun.com\/Ludo\/entry\/subversion_auth&#8230;on_through_ldap_with<br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[394],"class_list":["post-1789","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-subversion"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=1789"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1789\/revisions"}],"predecessor-version":[{"id":1790,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1789\/revisions\/1790"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=1789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=1789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=1789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}