Svn – Subversion gives Error 500 until authenticating with a web browser

500-errorapache-2.2svn

We used to use Collabnet SVN/Apache combo on a Windows server with LDAP authentication, and whilst the performance wasn't brilliant it used to work perfectly.

After switching to a fresh Ubuntu 10 install, and setting up an Apache/SVN/LDAP configuration, we have HTTPS access to our repositories, using Active Directory authentication via LDAP.

We're now having a very peculiar issue. Whenever a new user accesses a repository, our SVN clients (we have a few depending on the tool, but for arguments sake, let's stick to Tortoise SVN) report "Error 500 – Unknown Response". To get around this, we have to log into the repo using a web browser and navigate 'backwards' until it works

E.G:

  1. SVN Checkout https://svn.example.local/SVN/MyRepo/MyModule/ – Error 500 (bad)
  2. Webbrowse to https://svn.example.local/SVN/MyRepo/MyModule/ – Error 500 (bad)
  3. Webbrowse to https://svn.example.local/SVN/MyRepo/ – Error 500 (bad)
  4. Webbrowse to https://svn.example.local/SVN/ – Forbidden 403 (correct)
  5. Webbrowse to https://svn.example.local/SVN/MyRepo/ – OK 200 (correct)
  6. SVN Checkout https://svn.example.local/SVN/MyRepo/MyModule/ – Error 500 (bad)
  7. Webbrowse to https://svn.example.local/SVN/MyRepo/MyModule/ – OK 200 (correct)
  8. SVN Checkout https://svn.example.local/SVN/MyRepo/MyModule/ – OK 200 (correct)

It seems to require authentication up the tree, starting from the svnparentpath up through to the module required.

Has anyone seen anything like this before? Any ideas on where to start before I ditch it back to Collabnet's SVN server?

Update

Using Apache2, Here is the /svn location from my httpd.conf:

<Location /svn>
  DAV svn
  SVNParentPath /var/lib/svn
  AuthName "Subversion Repositories"
  AuthType Basic
  AuthBasicProvider ldap
  AuthzLDAPAuthoritative off
  AuthLDAPURL "ldap://dc1.domain.local:389/DC=domain,DC=local?sAMAccountName?sub?(objectClass=*)" NONE
  AuthLDAPBindDN "domain\apacheaccount"
  AuthLDAPBindPassword superawesomepassword
  require valid-user
</Location>

The only errors in /var/logs/apache2/error.log are legitimate authentication errors from when I've used the wrong password. In the access.log, an Error 500 line looks like:

192.168.161.101 - fname.sname [11/May/2010:08:39:08 +1000] "OPTIONS /svn/MyRepo HTTP/1.1" 500 634 "-" "SVN/1.6.6 (r40053) neon/0.28.6"

Best Answer

I'm using a Debian "Lenny" setup, running Apache2/SVN with LDAP being authenticated through Apache directly to AD, while also hosting a Trac site on the same machine. I'll take a stab at it, but I need some more info...

The SVN access is the built-in module through Apache, so the first question I have is - are you running this as the SVN stand-alone process, or through Apache (it appears to be Apache but I just want to be sure)? The second question is, are you using Apache2 or Apache (1.x)? The third question is, do you use LDAP authentication through PAM, or through Apache's built-in support?

Just for reference, here's a (sanitized) version of the config for Trac, along with the LDAP settings that authenticate through AD (yes, it's open to anyone because Trac has its own permissions system that on my setup defaults to read-only for authenticated users):

#Rudimentary Apache2 authentication for Active Directory (without group controls)
<Location /trac>
  SetHandler mod_python
  PythonInterpreter main_interpreter
  PythonHandler trac.web.modpython_frontend
  PythonOption TracEnvParentDir /srv/trac
  PythonDebug on
  Order deny,allow
  Deny from all
  Allow from 10.0.0.0/8
  AuthType Basic
  AuthName "Trac Projects"
  AuthBasicProvider "ldap"
  AuthLDAPURL "ldap://enterprise-dc.mycompany.com:3268/DC=localsite,DC=mycompany,DC=com?sAMAccountName?sub?(objectClass=user)"
  AuthLDAPBindDN       apache-account@local-site.mycompany.com
  AuthLDAPBindPassword "supersecretpasswordthatnoonewillguess"
  authzldapauthoritative On
  require valid-user
  # require ldap-group "CN=Users,DC=local-site,DC=mycompany,DC=com"
</Location>

More importantly for your purposes, using that form of authentication as a template, we can get the settings for /etc/apache2/mods-enabled/dav_svn.conf, which will control your SVN access:

<Location /svn>
  DAV svn
  SVNParentPath /srv/svn
  SVNAutoversioning on
  Order deny,allow
  Deny from all
  Allow from 10.0.0.0/8
  AuthType Basic
  AuthName "Subversion Repository"
  AuthBasicProvider "ldap"
  AuthLDAPURL "ldap://enterprise-dc.mycompany.com:3268/DC=local-site,DC=mycompany,DC=com?sAMAccountName?sub?(objectClass=user)"
  AuthLDAPBindDN apache-account@local-site.mycompany.com
  AuthLDAPBindPassword "supersecretpasswordthatnoonewillguess"
  authzldapauthoritative On
  require valid-user
</Location>

Our desktops have fairly tight controls on program installation so I'm not as concerned about someone (a) installing an SVN client (b) figuring out the exact server name to connect to (c) getting into the repo and mucky-mucking things up, which is why the security is so low. However, with a little tweaking, you should be able to re-use this arrangement by enforcing an AD group (note the commented out cruft in the first example) and get much tighter control on access.

Hope this is of help to you.


Update (based on new information)

I think the problem is that you are not authenticating against the Global Catalog. Change the port number to the one I have in my example, and be sure to point it at a Domain Controller that is at the "Enterprise" level i.e. not a member of a child domain. So instead of site.enterprise.com, point it to enterprise.com at the new port number. Note that you might not need to specify the domain name in your setup for the user name, so if it refuses to authenticate, be sure to try it without as well (see the example I posted); and use the "email-style" account name as well vs. the "domain-style" layout.

My suspicion: The Global Catalog "flattens" the search space for users; but by asking a standard LDAP query on the child DC, I think that the initial failure occurs because there is no "answer" to be had initially, until the DC in the child domain can run out and get one. On the second attempt, the answer is cached, and you succeed.

Related Topic