Sal
Peter Hoffmann Director Data Engineering at Blue Yonder. Python Developer, Conference Speaker, Mountaineer

Authenticate Trac against a MySQL Table

Recently I had to set up a trac instance which had to reuse authentification from an existing application.

Using Apache2 with Auth_MySQL it's really easy:

ScriptAlias /trac /var/www-trac/deploy/cgi-bin/trac.fcgi/
    <Location "/trac">
            AuthName "Please Authenticate"
            AuthType Basic
            require valid-user
            AuthUserFile /dev/null
            AuthBasicAuthoritative Off

            Auth_MySQL On
            Auth_MySQL_Host localhost
            Auth_MySQL_User dbuser 
            Auth_MySQL_Password dbpw
            Auth_MySQL_DB dbname
            Auth_MySQL_Password_Table Users
            Auth_MySQL_Username_Field username
            Auth_MySQL_Password_Field passwd
            Auth_MySQL_Encryption_Types Plaintext
            Auth_MySQL_Authoritative Off
    </Location>