changeset 238:b80624429934

added cfg.user_autocreate, for now for auth.http and auth.ssl_clientcert imported from: moin--main--1.5--patch-241
author Thomas Waldmann <tw@waldmann-edv.de>
date Fri, 25 Nov 2005 20:55:24 +0000
parents ccfa707e7064
children 9ae17b303304
files MoinMoin/auth.py MoinMoin/multiconfig.py MoinMoin/user.py docs/CHANGES
diffstat 4 files changed, 28 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth.py	Thu Nov 24 19:21:37 2005 +0000
+++ b/MoinMoin/auth.py	Fri Nov 25 20:55:24 2005 +0000
@@ -58,9 +58,8 @@
                 username = username.title()
             u = user.User(request, auth_username=username)
 
-    # XXX create (user? maybe should not happen here, but one layer higher to be
-    # common for all auth methods
-
+    if u:
+        u.create_or_update()
     if u and u.valid:
         return u
     else:
@@ -97,9 +96,8 @@
                     u = None
                 #u = user.User(request, auth_username=username)
 
-    # XXX create (user? maybe should not happen here, but one layer higher to be
-    # common for all auth methods
-
+    if u:
+        u.create_or_update()
     if u and u.valid:
         return u
     else:
--- a/MoinMoin/multiconfig.py	Thu Nov 24 19:21:37 2005 +0000
+++ b/MoinMoin/multiconfig.py	Fri Nov 25 20:55:24 2005 +0000
@@ -299,6 +299,7 @@
     theme_force = False
     trail_size = 5
     tz_offset = 0.0 # default time zone offset in hours from UTC
+    user_autocreate = False # do we auto-create user profiles
     user_email_unique = True # do we check whether a user's email is unique?
 
     # a regex of HTTP_USER_AGENTS that should be excluded from logging
--- a/MoinMoin/user.py	Thu Nov 24 19:21:37 2005 +0000
+++ b/MoinMoin/user.py	Fri Nov 25 20:55:24 2005 +0000
@@ -130,7 +130,8 @@
     @return: user name that can be used in acl lines
     """
     name = name.replace('_', ' ') # we treat _ as a blank
-    username_allowedchars = "'" # ' for names like O'Brian. "," and ":" must not be allowed (ACL delimiters).
+    username_allowedchars = "'@." # ' for names like O'Brian or email addresses.
+                                  # "," and ":" must not be allowed (ACL delimiters).
     # Strip non alpha numeric characters (except username_allowedchars), keep white space
     name = ''.join([c for c in name if c.isalnum() or c.isspace() or c in username_allowedchars])
 
@@ -283,7 +284,16 @@
         # use it reliably in edit locking
         from random import randint
         return "%s.%d" % (str(time.time()), randint(0,65535))
-            
+
+    def create_or_update(self, changed=False):
+        """ Create or update a user profile
+
+        @param changed: bool, set this to True if you updated the user profile values
+        """
+        if self._cfg.user_autocreate:
+            if not self.valid and not self.disabled or changed: # do we need to save/update?
+                self.save() # yes, create/update user profile
+                                
     def __filename(self):
         """ Get filename of the user's file on disk
         
--- a/docs/CHANGES	Thu Nov 24 19:21:37 2005 +0000
+++ b/docs/CHANGES	Fri Nov 25 20:55:24 2005 +0000
@@ -11,6 +11,17 @@
   Other changes:
     * Added irc:// to the builtin supported link schemas. You can remove it
       from config.url_schemas in case you have patched it in there.
+    * Added cfg.user_autocreate (default: False). Use True to enable user
+      profile autocreation, e.g. when you use http authentication, so your
+      externally authenticated users don't need to create their moin profile
+      manually. The auth method (see cfg.auth list) must check this setting
+      if it supports auto creation.
+    * Added user_autocreate support for auth.http and auth.ssl_clientcert.
+    * Added "." and "@" to allowed characters in usernames. This is needed
+      e.g. when using mod_pubcookie for authentication. mod_pubcookie returns
+      userids like "geek@ANDREW.CMU.EDU" (e.g. the Kerberos domain is part of
+      the id). Thanks to Brian E. Gallew for his patch, which we used for
+      inspiration for user autocreation changes.
 
 Version 1.5.0beta4:
   Fixes: