<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JohnMark.org Headquarters &#187; apache</title>
	<atom:link href="http://www.johnmark.org/blog/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johnmark.org/blog</link>
	<description>Just another John Mark production</description>
	<lastBuildDate>Sat, 24 Dec 2011 09:43:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Subversion with Apache and LDAP: Updated</title>
		<link>http://www.johnmark.org/blog/2009/03/subversion-with-apache-and-ldap-updated/</link>
		<comments>http://www.johnmark.org/blog/2009/03/subversion-with-apache-and-ldap-updated/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 16:53:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Submerged]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[Subversion Server]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[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...]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://blogs.open.collab.net/svn/2007/03/subversion_ldap.html" title="Subversion LDAP Authentication with Apache">previous blog</a><br />
   entry discussing Subversion, Apache and LDAP is nearing two years old.<br />
   It was written when Apache 2.0.x was still the mainstream and when Apache<br />
   2.2.x was released, changes in the LDAP modules and their respective<br />
   configuration directives has left my previous entry very confusing for<br />
   those wanting to use Apache 2.2.x.  The purpose of the <strong>Definitive<br />
   Guide</strong> is to provide a single location for questions for Apache<br />
   2.0.x and 2.2.x, while also providing more depth about things to consider<br />
   when building your Apache-based Subversion server using LDAP for<br />
   authentication.</p>
<h2>The Configuration</h2>
<p>For those of you that just want to get to the point, where you can copy<br />
   and paste and move on, here you go:</p>
<h3>Example Apache 2.2.x Configuration Snippet</h3>
<pre >
# 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 &quot;%t %u %{SVN-ACTION}e&quot; env=SVN-ACTION

&lt;Location /repos/&gt;
  # 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 &quot;Your Subversion Repository&quot;

  # Do basic password authentication in the clear
  AuthType Basic

  # The name of the protected area or &quot;realm&quot;
  AuthName &quot;Your Subversion Repository&quot;

  # Make LDAP the authentication mechanism
  AuthBasicProvider ldap

  # Make LDAP authentication is final
  AuthzLDAPAuthoritative on

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

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

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

  # Require a valid user
  Require valid-user

  # Authorization file
  AuthzSVNAccessFile /subversion/apache2/auth/repos.acl
&lt;/Location&gt;</pre>
<h3>Example Apache 2.0.x Configuration Snippet</h3>
<pre >
# 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 &quot;%t %u %{SVN-ACTION}e&quot; env=SVN-ACTION

&lt;Location /repos/&gt;
  # 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 &quot;Your Subversion Repository&quot;

  # LDAP Authentication is final
  AuthLDAPAuthoritative on

  # Do basic password authentication in the clear
  AuthType Basic

  # The name of the protected area or &quot;realm&quot;
  AuthName &quot;Your Subversion Repository&quot;

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

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

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

  # Require authentication
  Require valid-user

  # Authorization file
  AuthzSVNAccessFile /subversion/apache2/auth/repos.acl
&lt;/Location&gt;</pre>
<p><strong>(The configurations above were for pointing to an Active Directory (AD)<br />
   server.</strong></p>
<h2>Understanding the Configuration</h2>
<p>So&#8230;the above Apache configurations are what I personally use when<br />
   building an Apache-based server.  Obviously there are changes that need<br />
   to be made depending on the environment in but for now, it&#8217;s a great<br />
   start.  To make the best of this opportunity, let&#8217;s talk about the<br />
   miscellaneous parts of the configuration.</p>
<h3>SVNListParentPath and Subversion&#8217;s authz</h3>
<p>One of the first problems people run into when building an Apache-based<br />
   Subversion server is when they want to have mod_dav_svn serve a list of<br />
   repositories.  Everything works fine until they enable Subversion&#8217;s<br />
   authorization (authz) support.  What happens is the server will be<br />
   configured properly and secured properly but when you go to the<br />
   repository collection list, which in our case is http://localhost/repos,<br />
   you are forbidden to view the collection even if you have access.  Well,<br />
   with the <strong>RedirectMatch</strong> closer to the top of the<br />
   configuration, you fix this issue.  How you might be asking and the<br />
   reason is that when you enable authz, you must have a trailing slash<br />
   at the end of the collection url.  With the RedirectMatch, we<br />
   automatically redirect urls to the collection listing when there is no<br />
   trailing slash.  Problem solved.</p>
<h3>Custom Subversion Logging</h3>
<p>Subversion uses Apache&#8217;s WebDAV support for providing access to its<br />
   repositories when using Apache.  Unfortunately, when you look at Apache&#8217;s<br />
   access logs to try and see your Subversion usage, you end up with a lot<br />
   of WebDAV communication being logged and you only see a portion of the<br />
   actual client/server communication.  This is because mod_dav_svn uses<br />
   Apache subrequests and Apache does not log subrequests.  Even if it did,<br />
   turning the Subversion communication in the Apache access log into<br />
   something meaningful would be nearly impossible.  That being said,<br />
   the configuration above has been setup to use one of Subversion&#8217;s<br />
   features: <a href="http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html#svn.serverconfig.httpd.extra.logging" title="Apache Subversion Logging">Apache Logging</a> which<br />
   takes the guess work out.</p>
<h3>Subversion Configuration</h3>
<p>The other Subversion-specific parts of the Apache configuration are<br />
   pretty self-explanitory.  To summarize what is enabled with the above:</p>
<ul>
<li>SVNListParentPath: Enables the ability to browse the location root and<br />
      get a list of repositories being served by that url base</li>
<li>SVNAutoversioning: Enables the use of WebDAV clients to make changes<br />
      to the repository contents without using a Subversion client</li>
<li>SVNParentPath: Enables serving N number of repositories for the<br />
      url base</li>
<li>SVNReposName: Enables you to put in your own text to be visible in<br />
      the web browser when browsing your repository contents via the<br />
      built-in repository browser provided by mod_dav_svn</li>
<li>AuthzSVNAccessFile: Tells Subversion&#8217;s mod_authz_svn module where<br />
      to find the authz file.</li>
</ul>
<p>For more details about the Subversion-specific Apache directives, and<br />
   a list of even more ways you can configure your Apache-based Subversion<br />
   server, view the <a href="http://svnbook.red-bean.com/nightly/en/svn.ref.mod_dav_svn.conf.html" title="mod_dav_svn Documentation">mod_dav_svn</a><br />
   and the <a href="http://svnbook.red-bean.com/nightly/en/svn.ref.mod_authz_svn.conf.html" title="mod_authz_svn Documentation">mod_authz_svn</a><br />
   documentation.</p>
<h3>LDAP Configuration</h3>
<p>The LDAP portion of the Apache configuration is where most people run<br />
   into problems.  That being said, we&#8217;ll spend a little more time<br />
   explaining the Apache LDAP configuration.  The most important thing to<br />
   note is the subtle differences between Apache 2.0.x and Apache 2.2.x:</p>
<pre >
Apache 2.0.x           | Apache 2.2.x
-----------------------------------------------
AuthLDAPAuthoritative  | AuthzLDAPAuthoritative
AuthLDAPBindDN         | AuthLDAPBindDN
AuthLDAPBindPassword   | AuthLDAPBindPassword
AuthLDAPURL            | AuthLDAPURL
                       | AuthBasicProvider</pre>
<p>You should note that the Apache LDAP module names have also changed<br />
   between Apache 2.0.x and 2.2.x.  Now that we see the naming changes,<br />
   let&#8217;s talk about how to properly use these Apache directives to get<br />
   the LDAP-based authentication you&#8217;re looking for.  <strong>(I will be<br />
   using the Apache 2.2.x names for the Apache directives.  If you&#8217;re<br />
   still using Apache 2.0.x, please refer to the table above for how to<br />
   take my documentation and apply it to Apache 2.0.x.)</strong></p>
<ul>
<li>AuthzLDAPAuthoritative: Tells Apache whether or not a failed<br />
      authentication request can be passed to other Apache modules</li>
<li>AuthLDAPBindDN: The distinguished name of the user account that<br />
      Apache will use to connect to the directory system to perform its<br />
      user authentication</li>
<li>AuthLDAPBindPassword: The password for the user account configured<br />
      via the AuthLDAPBindDN directive</li>
<li>AuthLDAPURL: This is a url that tells where the directory server<br />
      is, where to look for users at, what user attribute is used to<br />
      identify a user and other miscellaneous things specific to the<br />
      LDAP query syntax  (More on this later.)</li>
<li>AuthBasicProvider: This tells Apache which authentication module<br />
      you want to use for Basic authentication</li>
</ul>
<p>All of the directives above are pretty straight forward except for<br />
   the <strong>AuthLDAPURL</strong> directive.  This directive we will<br />
   discuss in more detail below.  For any other Apache configuration<br />
   questions, please resort to the <a href="http://httpd.apache.org/docs/" title="Apache Documentation"><br />
   Apache Documentation</a> for your respective Apache version.</p>
<h3>The LDAP Query URL</h3>
<p>For most, the <strong>AuthLDAPURL</strong> directive is the most<br />
   challenging to understand.  There is good reason for this.  That<br />
   one directive actually consists of 6+ pieces of information that<br />
   will be different for each Subversion server.  Let&#8217;s break our<br />
   example <strong>AuthLDAPURL</strong> into its pieces and discuss<br />
   the importance, and nuances, of each.</p>
<p>For simplicity, here is the url again, in its entirety:<br />
   ldap://your.domain:389/DC=your,DC=domain?sAMAccountName?sub?(objectClass=*)</p>
<ul>
<li>Url scheme: [ldap] This is nothing more than a url scheme.<br />
      It will usually be either &#8216;ldap&#8217; or &#8216;ldaps&#8217; in the event that<br />
      you&#8217;re using SSL for accessing your directory server.</li>
<li>Hostname: [your.domain] This is the ip address or hostname<br />
      of your directory server.</li>
<li>Port: [389] This is the port the server is listening on for<br />
      directory server communication.</li>
<li>Search Base: [DC=your,DC=domain] This is the distinguished name<br />
      to the path in the directory tree that you want to search<br />
      for users.</li>
<li>Username attribute: [sAMAccountName] This is the attribute<br />
      contains the login name being used.</li>
<li>Query scope: [sub] This tells the directory server what type<br />
      of query to perform.</li>
<li>Filter: [(objectClass=*)] This tells the directory server to<br />
      filter the query for objects matching a particular filter</li>
</ul>
<p>For more details on constructing an ldap url, which is a standard<br />
   and not specific to Apache, view <a href="http://www.ietf.org/rfc/rfc2255.txt" title="RFC 2255">RFC 2255</a>.</p>
<h2>Working with Active Directory</h2>
<p>Active Directory is known as a <strong>Multi-Master Directory<br />
   System</strong>.  This being said, each directory server in AD<br />
   does not always have all the necessary information to perform all<br />
   directory server requests.  The best way to handle this is to have<br />
   Apache query a <strong>Global Catalog</strong>.  A Global Catalog<br />
   server has the ability to search at the whole forest for users.<br />
   This means if you want to do domain-wide searches or larger, you<br />
   need to point to a Global Catalog and you need to update your<br />
   Apache configuration accordingly.  When using a Global Catalog,<br />
   you should be using port 3268 when performing your queries.</p>
<h2>Searching for Users</h2>
<p>In the example url above, the <strong>sAMAccountName</strong><br />
   attribute is used to identify the username.  This attribute is<br />
   Windows/Active Directory specific so for those of you using<br />
   OpenLDAP or another option, that attribute probably will not exist.<br />
   Change your attribute accordingly.  An example is if you wanted to<br />
   use the <strong>Common Name</strong> to login, you could specify<br />
   &quot;CN&quot; as the attribute.</p>
<h2>LDAP Query Tuning</h2>
<p>The last thing we will talk about is the ability to use filters to<br />
   make your LDAP query a little more specific.  In the example url above<br />
   we used &quot;(objectClass=*)&quot;, which will search for all objects.  If you<br />
   know that you only want to search for a particular object type, like<br />
   the &quot;user&quot; type, you could use &quot;(objectClass=user)&quot; instead.</p>
<h2>Conclusion</h2>
<p>Building an Apache-based Subversion server with LDAP as the<br />
   authentication mechanism can be daunting for some.  I hope this<br />
   has made things easier for you.</p>
<p><map name='google_ad_map_1485_bdfb6b8d2a9af00f'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/1485?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_1485_bdfb6b8d2a9af00f' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=1485&amp;url= http%3A%2F%2Fwww.johnmark.org%2Fblog%2F2009%2F03%2Fsubversion-with-apache-and-ldap-updated%2F' /></p>]]></content:encoded>
			<wfw:commentRss>http://www.johnmark.org/blog/2009/03/subversion-with-apache-and-ldap-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

