Siteminder Authentication Overview

Many enterprise IT environments use Netegrity© SiteMinder© (hereafter called SiteMinder) to secure Web applications and servers. Enterprise applications often use siteminder as authentication mechanism - this is often a showstopper for opensource-applications.

This article describes how to configure and customize authentication for moinmoin wiki using SiteMinder as the authentication engine. This article assumes that you already have installed a SiteMinder webagent and a moinmoin wiki, and that they are working properly.

Configuration details:

Detailed configuration

Siteminder configuration

MoinMoin Wiki Configuration

Add the following lines to your wiki configuration : wikiconfig.py

from MoinMoin.multiconfig import DefaultConfig

class Config(DefaultConfig):

    def external_cookie(request, **kw):
        """ authenticate via external cookie """
        import Cookie
        user = None
        try_next = True # if True, moin tries the next auth method
        cookiename = "SMSESSION" # use the siteminder session cookie as idicator for proper logon
        user_header = "HTTP_SM_USER" # user the username provided in the http header

        try:
            cookie = Cookie.SimpleCookie(request.saved_cookie)
        except Cookie.CookieError:
            # ignore invalid cookies
            cookie = None
        if cookie and cookie.has_key(cookiename):
            import urllib

            cookievalue = cookie[cookiename].value
            cookievalue = urllib.unquote(cookievalue) # cookie value is urlencoded, decode it
            cookievalue = cookievalue.decode('iso-8859-1') # decode cookie charset to unicode
            cookievalue = cookievalue.split('#') # cookie has format loginname#firstname#lastname#email

            if (request.env.has_key(user_header)):
                auth_username = request.env[user_header]
            else:
                sys.exit(1)

            aliasname = email = ''

            from MoinMoin.user import User
            # giving auth_username to User constructor means that authentication has already been done.
            user = User(request, name=auth_username, auth_username=auth_username)

            changed = False
            if aliasname != user.aliasname: # was the aliasname externally updated?
                user.aliasname = aliasname ; changed = True # yes -> update user profile
            if email != user.email: # was the email addr externally updated?
                user.email = email ; changed = True # yes -> update user profile

            if user:
                user.create_or_update(changed)
            if user and user.valid: # did we succeed making up a valid user?
                try_next = False # stop processing auth method list
        return user, try_next


    from MoinMoin.auth import moin_cookie, http
    # user external cookie for auth
    auth = [external_cookie]
    # cautomatically create a user
    user_autocreate = True
    # disable unneccessary configuration switches in the user-preferences page
    user_form_remove = ['aliasname', 'password', 'password2', 'logout', 'create', 'name']
    user_checkbox_remove = ['remember_me', 'disabled']
....
....

Apache configuration

Add the following lines to httpd.conf of your apache webserver:

# Script alias for unauthenticated requests (public access)
ScriptAlias /wiki "/srv/wiki/data_store/test/config/moin.cgi"
# Script alias for authenticated requests (protected access)
ScriptAlias /protected-wiki "/srv/wiki/data_store/test/config/moin.cgi"

# Automatically redirect the logout request to the siteminder-logout url
# https://<protected>/protected-wiki/UserPreferences?action=logout&logout=logout
RewriteEngine On
RewriteCond %{QUERY_STRING} ^.*action=logout&logout=logout.*$
RewriteRule ^/protected-form.*$ http://corporate.net/internal/logoff [R=301,L]

# Automatically redirect the login request to the protected wikispace
RewriteCond %{QUERY_STRING} ^.*action=login.*$
RewriteRule ^/wiki(.*)$ ^/protected-form/$1 [R=301,L]

MoinMoin: AuthMarket/SiteminderAuthentication (last edited 2008-01-31 19:22:05 by ThomasWaldmann)