Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first import

  • Loading branch information...
commit 47fc2cf79435833083a7f459ee9a9dbb465f47d8 0 parents
@iamcal authored
30 README.md
@@ -0,0 +1,30 @@
+Trac SSO
+========
+
+Single Sign-on (SSO) support for Trac.
+This plugin is set up to use <a href="http://github.com/exflickr/GodAuth">GodAuth</a>,
+but can easily be modified to use other SSO systems.
+
+
+Installation
+------------
+
+First you'll need to build the egg.
+Once you have python and setuptools installed (which you probably already do, for Trac), you can just:
+
+ python setup.py bdist_egg
+
+That will build an egg in the <code>dist/</code> folder.
+
+Copy the egg file into the <code>plugins/</code> folder of your Trac install.
+
+Next you'll need to enable the new authentication module in your configuration file,
+which can be found at <code>conf/trac.ini</code> inside your trac install. Add these lines to the bottom:
+
+ [components]
+ trac.web.auth.* = disabled
+ godauth.* = enabled
+
+If your config file already has a <code>[components]</code> section, just append those 2 lines to it.
+
+Finally, restart your webserver. That should be it.
3  godauth/__init__.py
@@ -0,0 +1,3 @@
+# This is a python package
+from godauth.env import *
+
60 godauth/auth.py
@@ -0,0 +1,60 @@
+import os
+
+from trac.core import *
+from trac.web.api import IAuthenticator, IRequestFilter
+from trac.web.chrome import INavigationContributor
+from trac.util import escape, hex_entropy, TracError, Markup
+
+
+class GodAuthLoginModule(Component):
+
+ implements(IAuthenticator, INavigationContributor, IRequestFilter)
+
+ #
+ # IAuthenticator methods
+ #
+
+ def authenticate(self, req):
+ authname = None
+
+ user = os.getenv("GodAuth_User")
+ if user is not None:
+ authname = user
+
+ if not authname:
+ return None
+
+ if self.config.getbool('trac', 'ignore_auth_case'):
+ authname = authname.lower()
+
+ return authname
+
+
+ #
+ # INavigationContributor methods
+ #
+
+ def get_active_navigation_item(self, req):
+ return 'login'
+
+ def get_navigation_items(self, req):
+ if req.authname and req.authname != 'anonymous':
+ yield 'fake', 'fake', 'fake'
+ else:
+ yield 'metanav', 'login', Markup('<span class="tinylogin">Log in above to edit stuff</span>')
+
+
+ #
+ # IRequestFilter methods
+ #
+
+ def pre_process_request(self, req, handler):
+ return handler
+
+ def post_process_request(self, req, template, content_type):
+ req.hdf.removeTree('chrome.nav.metanav.help')
+ req.hdf.removeTree('chrome.nav.metanav.about')
+ if not req.authname or req.authname == 'anonymous':
+ req.hdf.removeTree('chrome.nav.metanav.settings')
+ return template, content_type
+
18 godauth/perm.py
@@ -0,0 +1,18 @@
+from trac.core import *
+from trac.perm import IPermissionGroupProvider
+from trac.util import TracError
+
+class FlAuthPermissionGroupProvider(Component):
+
+ implements(IPermissionGroupProvider)
+
+ def get_permission_groups(self, username):
+ groups = ['anonymous']
+ if username == 'Anonymous':
+ return groups
+
+ if username == 'cal':
+ groups.append('admins')
+
+ return groups
+
4 setup.cfg
@@ -0,0 +1,4 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = false
+
24 setup.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+from setuptools import setup, find_packages
+
+PACKAGE = 'TracGodAuth'
+VERSION = '0.1'
+
+setup(
+ name=PACKAGE, version=VERSION,
+ description='Trac plugin for SSO authn/authz',
+ author="Cal Henderson", author_email="cal@iamcal.com",
+ license='Private', url='http://code.iamcal.com',
+ packages=find_packages(exclude=['ez_setup', '*.tests*']),
+ package_data={
+ 'godauth': []
+ },
+ entry_points = {
+ 'trac.plugins': [
+ 'godauth.auth = godauth.auth',
+ 'godauth.perm = godauth.perm',
+ ]
+ }
+)
+
Please sign in to comment.
Something went wrong with that request. Please try again.