Allow anonymous users to view LDAP protected site

Description

Using Http AuthType Basic configured for LDAP does not allow anonymous users to see the trac site. Here is my workaround...

Edit the /etc/httpd/conf.d/trac.d file (or just /etchttpd/conf/httpd.conf) as follows

<Location /trac/publicexampleproject>
   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnv /opt/trac/exampleproject
   PythonOption TracUriRoot /trac/publicexampleproject
   SetEnv PYTHON_EGG_CACHE /opt/trac/eggcache
  RewriteEngine On
  RewriteRule /login https://%{SERVER_NAME}/trac/exampleproject [R]
</Location>
<Location /trac/exampleproject>
   SetHandler mod_python
   PythonInterpreter main_interpreter
   PythonHandler trac.web.modpython_frontend
   PythonOption TracEnv /opt/trac/exampleproject
   PythonOption TracUriRoot /trac/exampleproject

   AuthType Basic
   AuthName "example project secure area"
   AuthLDAPEnabled on
   AuthLDAPAuthoritative on
   AuthLDAPBindDN "CN=Manager,DC=subnet,DC=example,DC=com"
   AuthLDAPBindPassword xxxxxxxx
   AuthLDAPURL ldap://subnet.example.com:389/ou=people,dc=subnet,dc=example,dc=com?uid?sub?(objectClass=*)
  
   Options Indexes FollowSymLinks
   Require valid-user
   RewriteEngine On
   RewriteCond %{HTTPS} !on
   RewriteRule ^/(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R]
   SetEnv PYTHON_EGG_CACHE /opt/trac/eggcache
</Location>

Bugs/Feature Requests

Existing bugs and feature requests for LdapAnonymousIntegration are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from here.

Source

You can check out LdapAnonymousIntegration from here using Subversion, or browse the source with Trac.

Example

Now when you go to http://example.com/trac/publicexampleproject you can view it as anonymous (without prompt for password). When you click on login you will be redirected to https://example.com/trac/exampleproject and prompted for your username and password.

Enjoy!

Recent Changes

[3162] by wmernagh on 01/31/08 02:34:02

New hack LdapAnonymousIntegration, created by wmernagh

Author/Contributors

Author: wmernagh
Contributors: