Authenticate Trac against Django
Description
I am no longer maintaining this. If you would like to take over, please feel free to.
I've worked up the beginnings of a Trac plugin that authenticates against Django users. I've since determined that I'm not likely to use it. So, if anyone is interested in maintaining it, feel free.
The basic functionality works. I can login to my django app and then I'm instantly logged into trac (without retyping my username and password). If I log out of my django app, I'm instantly logged out of trac.
It works by getting the django session from the django cookie and extracting the user from the django database. Of course, for this to work, both the trac and django instances need to be on the same machine (to access eachother) and behind the same domain (to access the cookie). I also have the beginnings of some code to assign permissions within django for trac via django's user groups. For some undetermined reason I haven't been able to override the login/out links in the nav and there's some debug code that needs removed.
A sample_trac.ini file that only contains the relevant settings has been included.
Note: I have not committed anything to svn. Scroll down to the bottom for the attached file.
I have attached some updated versions submitted to me by others (see below). I have not tested them and am not using this anymore. Use at your own risk.
Bugs/Feature Requests
Existing bugs and feature requests for DjangoAuthIntegration are here.
If you have any issues, create a new ticket.
Download
Download the zipped source from here.
Source
You can check out DjangoAuthIntegration from here using Subversion, or browse the source with Trac.
Example
Install the plugin and add the following settings to trac.ini:
[components] djangoauth.* = enabled [djangoauth] django_settings_module = myproject.settings use_django_perms = false login_url = /login/ logout_url = /logout/
- django_settings_module should point to the django settings file that is used for your project. The file needs to be on your pythonpath and importable.
- use_django_perms turns on or off the ability to set permission within the django admin. If used, assign your django users to groups that start with 'trac_'. So, users assigned to the 'trac_developer' group in django, would be assigned to the group 'developer' in trac. Note: All users must be 'active' in django regardless of this setting.
- login_url and logout_url should point to the login and logout urls of your django app. Unfortunately, they do not currently override the defaults as they should. I had intended to use django's 'next' feature to redirect back to trac after login but never got that far.
- configuration in apache, AuthType Basic, etc, is not needed.
Recent Changes
[2933] by waylan on 12/21/07 20:10:38
New hack DjangoAuthIntegration, created by waylan
Author/Contributors
Author: waylan
Contributors:
Attachments
- djangoauth.zip (4.6 kB) -
Initial version of the plugin. Rough around the edges, Perhaps someday I'll commit to svn.
, added by waylan on 12/21/07 20:13:03. - djangoauth.py (3.9 kB) -
Code updated by Katie Lohrenz and emailed to me on January 10, 2008.
, added by waylan on 07/01/08 16:09:34. - djangoauth_1.py (4.2 kB) -
Another iteration by Milan Andric which he emailed me on April 25, 2008.
, added by waylan on 07/01/08 16:12:02.

