changeset 184:56d74783ea93

WhoAmI wiki xmlrpc plugin and client script imported from: moin--main--1.5--patch-186
author Thomas Waldmann <tw@waldmann-edv.de>
date Thu, 03 Nov 2005 23:00:02 +0000
parents b4c7c65b6af0
children 8660860a50cf
files MoinMoin/scripts/xmlrpc-tools/WhoAmI.py MoinMoin/xmlrpc/WhoAmI.py docs/CHANGES
diffstat 3 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/WhoAmI.py	Thu Nov 03 23:00:02 2005 +0000
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+"""
+This script checks whether the wiki authenticates and trusts you.
+
+It calls the TrustMe.py xmlrpc plugin. To use http auth, you need to configure
+the srcwiki with auth = [http, moin_cookie] in its wikiconfig.
+
+GPL software, 2005 Thomas Waldmann
+"""
+
+user = "ThomasWaldmann"
+password = "wrong"
+
+import sys, xmlrpclib
+sys.path.insert(0, '../../..')
+from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
+
+srctrans = BasicAuthTransport(user, password)
+srcwiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de/?action=xmlrpc2", transport=srctrans)
+
+print srcwiki.WhoAmI()
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/xmlrpc/WhoAmI.py	Thu Nov 03 23:00:02 2005 +0000
@@ -0,0 +1,19 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - Tells who you are and whether the wiki trusts you.
+               
+
+    @copyright: 2005 by Thomas Waldmann (MoinMoin:ThomasWaldmann)
+    @license: GNU GPL, see COPYING for details.
+"""
+
+def execute(xmlrpcobj, *args):
+    request = xmlrpcobj.request
+    username = request.user.name
+    if not username:
+        username = "<unknown user>"
+    valid = request.user.valid
+    trusted = request.user.trusted
+    result = "You are %s. valid=%d, trusted=%d." % (username.encode("utf-8"), valid, trusted)
+    return xmlrpcobj._outstr(result)
+
--- a/docs/CHANGES	Tue Nov 01 20:25:39 2005 +0000
+++ b/docs/CHANGES	Thu Nov 03 23:00:02 2005 +0000
@@ -77,6 +77,10 @@
        valid user or None, use it like this:
            from MoinMoin.auth import http, moin_cookie
            auth = [http, moin_cookie]
+     * Added a WhoAmI.py wiki xmlrpc plugin to check whether auth works
+       correctly for xmlrpc. There is a counterpart script WhoAmI.py that
+       uses http auth when calling the xmlrpc plugin, so you can use it to
+       check http auth.
      * cfg.auth_http_enabled was removed, please use cfg.auth instead.
      * http auth now supports "Negotiate" scheme, too
      * Added sslclientcert auth method (Apache: untested, Twisted: not