changeset 295:91d47ebee530

make posted UserPreferences form values easily available for auth methods imported from: moin--main--1.5--patch-299
author Thomas Waldmann <tw@waldmann-edv.de>
date Tue, 06 Dec 2005 16:50:42 +0000
parents 3cbbedfb89af
children 4e08178a630c
files MoinMoin/auth.py MoinMoin/request.py contrib/auth_externalcookie/wikiconfig.py docs/CHANGES
diffstat 4 files changed, 38 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth.py	Mon Dec 05 22:50:34 2005 +0000
+++ b/MoinMoin/auth.py	Tue Dec 06 16:50:42 2005 +0000
@@ -4,7 +4,22 @@
 
     Here are some methods moin can use in cfg.auth authentication method list.
     The methods from that list get called (from request.py) in that sequence.
-    The called auth method the must return a tuple (user_obj, continue_flag).
+    They get request as first argument and also some more kw arguments:
+       name: the value we did get from a POST of the UserPreferences page
+             in the "name" form field (or None)
+       password: the value of the password form field (or None)
+       login: True if user has clicked on Login button
+       logout: True if user has clicked on Logout button
+       (we maybe add some more here)
+
+    Use code like this to get them:
+        name = kw.get('name') or ''
+        password = kw.get('password') or ''
+        login = kw.get('login')
+        logout = kw.get('logout')
+        request.log("got name=%s len(password)=%d login=%r logout=%r" % (name, len(password), login, logout))
+    
+    The called auth method then must return a tuple (user_obj, continue_flag).
     user_obj is either a User object or None if it could not make one.
     continue_flag is a boolean indication whether the auth loop shall continue
     trying other auth methods (or not).
@@ -30,7 +45,7 @@
 import Cookie
 from MoinMoin import user
 
-def moin_cookie(request):
+def moin_cookie(request, **kw):
     """ authenticate via the MOIN_ID cookie """
     try:
         cookie = Cookie.SimpleCookie(request.saved_cookie)
@@ -54,7 +69,7 @@
          thus, the server specific code would stay in request object implementation.
 """
 	 
-def http(request):
+def http(request, **kw):
     """ authenticate via http basic/digest/ntlm auth """
     from MoinMoin.request import RequestTwisted
     u = None
@@ -93,7 +108,7 @@
     else:
         return None, True
 
-def sslclientcert(request):
+def sslclientcert(request, **kw):
     """ authenticate via SSL client certificate """
     from MoinMoin.request import RequestTwisted
     u = None
@@ -146,7 +161,7 @@
     else:
         return None, True
 
-def interwiki(request):
+def interwiki(request, **kw):
     # TODO use auth_method and auth_attribs for User object
     # TODO use tuples as return value
     if request.form.has_key("user"):
--- a/MoinMoin/request.py	Mon Dec 05 22:50:34 2005 +0000
+++ b/MoinMoin/request.py	Tue Dec 06 16:50:42 2005 +0000
@@ -424,8 +424,17 @@
         return wikiutil.url_unquote(path, want_unicode=False), query        
                 
     def get_user(self):
+        # try to get some values from the maybe present UserPreferences form,
+        # so auth methods can use it as their user interface for login
+        name = self.form.get('name', [None])[0]
+        password = self.form.get('password', [None])[0]
+        login = self.form.has_key('login')
+        logout = self.form.has_key('logout')
+        
         for auth in self.cfg.auth:
-            user_obj, continue_flag = auth(self)
+            user_obj, continue_flag = auth(self,
+                                           name=name, password=password,
+                                           login=login, logout=logout)
             if not continue_flag:
                 break
         if user_obj is None:
--- a/contrib/auth_externalcookie/wikiconfig.py	Mon Dec 05 22:50:34 2005 +0000
+++ b/contrib/auth_externalcookie/wikiconfig.py	Tue Dec 06 16:50:42 2005 +0000
@@ -7,7 +7,7 @@
 # ...
 
 class FarmConfig(DefaultConfig):
-    def external_cookie(request):
+    def external_cookie(request, **kw):
         """ authenticate via external cookie """
         import Cookie
         user = None
--- a/docs/CHANGES	Mon Dec 05 22:50:34 2005 +0000
+++ b/docs/CHANGES	Tue Dec 06 16:50:42 2005 +0000
@@ -1,6 +1,13 @@
 MoinMoin Version History
 ========================
 
+Version 1.5.0current:
+  Other changes:
+    * Made it easier for auth methods needing a user interface (like ldap or
+      mysql stuff). Unlike http auth, they usually need some "login form".
+      We made UserPreferences login form values (name, password, login, logout)
+      available as kw args of the auth method, so it is easy and obvious now.
+
 Version 1.5.0beta5:
   Fixes:
     * Fixed a minor user interface bug: it showed RenamePage and DeletePage