AuthphpBB is an MoinMoin plugin that allows phpBB forum members to login to a MoinMoin wiki. AuthphpBB is not ready for use, this is work in progress!!!

AuthphpBB is based on JorgeLéon/RemoteAuth by Jorge Léon.

How to use

Inside your wiki directory, create a directory called "AuthphpBB". In that new directory, create an empty file called "__init__.py", and a file called "AuthphpBB.py". The contents for "AuthphpBB.py" should be:

   1 def AuthphpBB(request, **kw):
   2     """ authenticate to phpBB db
   3     Based on ftp auth by Jorge Leon
   4     """
   5     username = kw.get('name')
   6     password = kw.get('password')
   7     login = kw.get('login')
   8     user_obj = kw.get('user_obj')
   9     cfg = request.cfg
  10     verbose = cfg.auth_phpbb_verbose
  11     if verbose:
  12         request.log("phpBB: got name=%s login=%r" % (username, login))
  13     # we just intercept login, other requests have to be
  14     # handled by another auth handler
  15     if not login:
  16         return user_obj, True
  17     import sys#, re, ftplib
  18     import traceback
  19     from MoinMoin import user
  20     import MySQLdb, md5
  21     u = None
  22     try:
  23         connection = MySQLdb.connect(host=cfg.auth_phpbb_host,
  24                                      user=cfg.auth_phpbb_user,
  25                                      passwd=cfg.auth_phpbb_passwd,
  26                                      db=cfg.auth_phpbb_db)
  27         cursor = connection.cursor()
  28         cursor.execute("SELECT username, user_password" +
  29                        " FROM " + cfg.auth_phpbb_usertable +
  30                        " WHERE username = '"  + username + "'")
  31         data = cursor.fetchall()
  32         if md5.new(password).hexdigest() == data[0][1]:
  33                 u = user.User(request,
  34                               auth_username=username,
  35                               name=username,
  36                               password=password,
  37                               auth_method='phpbb',
  38                               auth_attribs=('name', 'auth_username', 'password',))
  39     except:
  40         info = sys.exc_info()
  41         request.log("phpBB: caught an exception, traceback follows...")
  42         request.log(''.join(traceback.format_exception(*info)))
  43     if u:
  44         u.create_or_update(True)
  45     return u, True

Add these lines to your wikiconfig.py and adjust them:

    from AuthphpBB import AuthphpBB
    from MoinMoin.auth import moin_cookie
    auth_phpbb_host = "SERVER_IP_(OR_URL?)"
    auth_phpbb_user = "username"
    auth_phpbb_passwd = "password"
    auth_phpbb_db = "database"
    auth_phpbb_usertable = "table"
    auth_phpbb_verbose = True # or False
    auth = [AuthphpBB.AuthphpBB, moin_cookie]
    user_autocreate=True

MoinMoin: JensGeiregat/AuthphpBB (last edited 2007-10-29 19:19:35 by localhost)