changeset 1953:97626bb218f4

interwiki auth: fixes and docs
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 06 Apr 2007 21:36:26 +0200
parents a05a3b447db5
children a0fa1656e37c
files MoinMoin/auth/interwiki.py docs/CHANGES
diffstat 2 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/interwiki.py	Fri Apr 06 19:40:03 2007 +0200
+++ b/MoinMoin/auth/interwiki.py	Fri Apr 06 21:36:26 2007 +0200
@@ -6,6 +6,9 @@
                 2007 by MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
+
+verbose = False
+
 import xmlrpclib
 from MoinMoin import auth, wikiutil, user
 
@@ -16,25 +19,30 @@
     user_obj = kw.get('user_obj')
 
     if login:
-        wikitag, wikiurl, wikitail, err = wikiutil.resolve_wiki(username)
+        if verbose: request.log("interwiki auth: trying to auth %r" % username)
+        username = username.replace(' ', ':', 1) # Hack because ':' is not allowed in name field
+        wikitag, wikiurl, name, err = wikiutil.resolve_wiki(request, username)
 
+        if verbose: request.log("interwiki auth: resolve wiki returned: %r %r %r %r" % (wikitag, wikiurl, name, err))
         if err or wikitag not in request.cfg.trusted_wikis:
             return user_obj, True
 
         if password:
             homewiki = xmlrpclib.Server(wikiurl + "?action=xmlrpc2")
-            account_data = homewiki.getUser(wikitail, password)
+            account_data = homewiki.getUser(name, password)
             if isinstance(account_data, str):
                 # e.g. "Authentication failed", TODO: show error message
+                if verbose: request.log("interwiki auth: %r wiki said: %s" % (wikitag, account_data))
                 return user_obj, True
 
             # TODO: check auth_attribs items
-            u = user.User(request, name=username, auth_method='interwiki', auth_attribs=('name', 'aliasname', 'password', 'email', ))
+            u = user.User(request, name=name, auth_method='interwiki', auth_attribs=('name', 'aliasname', 'password', 'email', ))
             for key, value in account_data.iteritems():
                 if key not in request.cfg.user_transient_fields:
                     setattr(u, key, value)
-            if u:
-                u.create_or_update(True)
+            u.valid = 1
+            u.create_or_update(True)
+            if verbose: request.log("interwiki: successful auth for %r" % name)
             return u, True # moin_session has to set the cookie
 
     return user_obj, True
--- a/docs/CHANGES	Fri Apr 06 19:40:03 2007 +0200
+++ b/docs/CHANGES	Fri Apr 06 21:36:26 2007 +0200
@@ -251,6 +251,7 @@
       * interwikiName -- method to get the IWID and the interwiki moniker
       * getAllPagesEx -- method to get the pagelist in a special way (revnos,
         no system pages etc.)
+      * getUser -- method to remotely authenticate a user and get profile data
     * IWID support - i.e. every wiki instance has a unique ID
     * The list of InterWiki sites is editable in the wiki (page InterWikiMap),
       it is getting reloaded every minute
@@ -340,6 +341,14 @@
       TODO: we need a copy icon in RC
     * Session handling for logged-in users and (not by default due to expiry
       problems) anonymous users.
+    * interwiki auth: You need to define cfg.trusted_wikis and
+       cfg.user_autocreate to use it. Logging in works by entering:
+      Name: RemoteWikiName RemoteUserName
+      Password: remotepass
+      Then moin contacts RemoteWikiName after looking it up in the interwiki
+      map and tries to authenticate there using RemoteUserName and remotepass.
+      If it succeeds, the remote wiki will return the remote user profile items
+      and your local moin will autocreate an account with these values.
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page