Re: RE: [Exuserfolder-users] Mailman based authentication?

[email protected] (Barry A. Warsaw) Mon, 25 Mar 2002 14:27:36 -0500
Newsgroups gmane.comp.web.zope.zmailman
Message-ID <[email protected]>
>>>>> "TT" == Trevor Toenjes <[email protected]> writes:

    TT> I have forwarded this to the zMailman list for comments.
    TT> This is an interesting requirement.

Thaks Trevor.

    >> Hey there all, I'm looking for a way to authenticate users in a
    >> directory based on their mailman email:password combo- I know
    >> this is a bit backwards, but the mailman user data is aleready
    >> there- and I want to simply provide a secure area for the list
    >> members- without new passwords etc...  I understand that
    >> mailman and Zope have some strong ties through python, but am
    >> worndering if anyone has created an authentication method based
    >> on mailman?  Also, I have no idea where mailman stores the
    >> password data- or how to create a way for exUsers to
    >> authenticate.

Given Mailman 2.1 as the basis, this wouldn't be hard to do.  MM2.1
defines an abstract membership interface so you don't have to worry
about where the member data is actually stored.  See
Mailman/MemberAdaptor.py.

The one gotcha is that MM2.1's user database is list-centric, meaning
you need to know the mailng list you're authenticating against in
order to look up member info.  This is a known historic design flaw
that will be fixed in MM3.0.

Here's a sketch of how to do it.  First, make sure that Mailman's
top-level package is on your sys.path.  Something like the following
ought to do it (assuming default installation directories):

    import sys
    sys.path.append('/usr/local/mailman')

Now, given a list name against which you want to authenticate a user,
here is a rough sketch:

    from Mailman.MailList import MailList

    mlist = MailList(listname, lock=0)
    if mlist.isMember(addr):
	# This is a placeholder for getting the user's response to a
	# challenge, e.g. a password field on a web form.
	response = challenge_user(addr)
	if mlist.authenticateMember(addr, response):
	    # Their password matched
	    success()
	else:
	    failure()

Hope that helps,
-Barry