119 Labs LLC

Ideas on Technology

Installing Auth Openid on Trac With Dreamhost

It turns out installing plugins, and particularly the openid plugin, on a shared dreamhost environment is arduous at best. �After a bit of work and research I managed to get it to work so here you go:

I. Perform a one-click install of trac from the web panel

if you don’t know how to do this you shouldn’t even try to proceed.

II. Setup a virtual python environment

Having a shared account with no sudo access you need to setup a local python environment to do all of the building. I found a reference here on how to do that. Here are the steps
cd ~ wget�virtual-python.py python virtual-python.py wget http://peak.telecommunity.com/dist/ez_setup.py bin/python ez_setup.py export PYTHONPATH=~/lib/python2.4/:~/lib/python2.4/site-packages/

III. Build the plugin

mkdir install_dir cd install_dir  
hg clone http://bitbucket.org/Dalius/authopenid-plugin/
cd authopenid-plugin python setup.py install –prefix=$HOME cp ~/lib/python2.4/site-packages/*.egg <your_trac>/plugins
For more info see this article.

IV. Configure openid

edit <your_trac>/conf/trac.ini
add the following lines:  
[components]
trac.web.auth.* = disabled
authopenid.* = enabled
see the above article for more config options.

V. Install Element Tree

As of this writing, element tree was not installed in the dream host system python cache. �In order to get around this do the following:
cd ~/install_dir wget�http://effbot.org/media/downloads/elementtree-1.2.6-20050316.tar.gz tar xzvf�elementtree-1.2.6-20050316.tar.gz cd�elementtree-1.2.6-20050316 setup.py install
In order to get our trac instance to pick up this library, we need to package it as an egg edit its setup.py change
from distutils.core import setup, Extension
to:
from setuptools import setup, Extension
then run
python setup.py bdist_egg cp dist/*.egg <your_trac>/plugins
you now have all of the files installed you need to run openid on trac

VI. Creating the plugin schema

If you go to you project home page and you see the message:
TracError: The Trac Environment needs to be upgraded.
Then like me you need to initialize the SQL tables used by the python-openid plugin. If that is the case then do the following:
cd <your_trac>/db sqlite3 trac.db CREATE TABLE oid_nonces(server_url VARCHAR); <hit enter> CREATE TABLE oid_associations(server_url VARCHAR(2047),handle VARCHAR(255),secret BLOB(128),issued INTEGER,lifetime INTEGER,assoc_type VARCHAR(64),PRIMARY KEY (server_url, handle)); <hit enter> .exit
See the�source code for more info. Now we need to “upgrade” the schema
cd ~/install-dir wget http://openidenabled.com/files/python-openid/packages/python-openid-2.2.4.tar.gz tar xzvf python-openid-2.2.4.tar.gz
cd �python-openid-2.2.4
cd �contrib ./upgrade-store-1.1-to-2.0 –sqlite=<your_trac>/db/trac.db
on the above line you must use the absolute path to your trac instance. No using ~ as a home dir shortcut. This should run successfully.If the output of that command is �”no such table oid…” Then something was messed up with using sqllite. Go back in and use the command .tables and make sure the two tables are there. If not, re-run the create table commands and look for error messages. DONE! You should now be able to log in to your trac instance.

VII. Setting OpenId permissions in trac

Setup your account with permissions.ant more? log in and check trac.log edit <your_trac>/conf/trac.ini change the logging section so it looks like this:
[logging] log_file = trac.log log_level = DEBUG log_type = file
save and exit. Now:
tail -n 200 -F <your_trac>/log/trac.log
Next log in to your trac instance (using a web browser) using a openid account. You’ll see something like�Retrieving session for ID u’http://xxxxxxxxxxxxxxxxxxxxxxxxx’ Everything between the single quotes is your account name. Now we can use trac-admin to give our openid account some permissions:
trac-admin <trac_instance> permission add <account_name> <PERMISSION>
where permission is something �like TRAC_ADMIN. �Use the command permission list to see currently assigned permissions

VIII. Cleanup

One thing I dislike about the one click install is it messes up the logo area. �Here’s a simple fix edit <your_trac>/.htaccess after the line RewriteCond $1 !^htdocs(.*).png$ add the line RewriteCond $1 !^chrome(.*).png$ save and the logo should now show up. Good luck. let me know if you run into other stumbling blocks and I’ll update the instructions.