changeset 1606:ae56d79ae076

http auth / ssl clientcert auth: correctly decode name/password/email to unicode (ported from 1.5)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 08 Oct 2006 20:00:21 +0200
parents c4f2db04084b
children 9131797454fb
files MoinMoin/auth/http.py MoinMoin/auth/sslclientcert.py MoinMoin/user.py
diffstat 3 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/http.py	Sun Oct 08 17:50:03 2006 +0200
+++ b/MoinMoin/auth/http.py	Sun Oct 08 20:00:21 2006 +0200
@@ -9,7 +9,7 @@
     @copyright: 2006 by MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
-from MoinMoin import user
+from MoinMoin import config, user
 from MoinMoin.request import TWISTED, CLI
 
 def http(request, **kw):
@@ -18,8 +18,8 @@
     u = None
     # check if we are running Twisted
     if isinstance(request, TWISTED.Request):
-        username = request.twistd.getUser()
-        password = request.twistd.getPassword()
+        username = request.twistd.getUser().decode(config.charset)
+        password = request.twistd.getPassword().decode(config.charset)
         # when using Twisted http auth, we use username and password from
         # the moin user profile, so both can be changed by user.
         u = user.User(request, auth_username=username, password=password,
@@ -29,7 +29,7 @@
         env = request.env
         auth_type = env.get('AUTH_TYPE', '')
         if auth_type in ['Basic', 'Digest', 'NTLM', 'Negotiate', ]:
-            username = env.get('REMOTE_USER', '')
+            username = env.get('REMOTE_USER', '').decode(config.charset)
             if auth_type in ('NTLM', 'Negotiate',):
                 # converting to standard case so the user can even enter wrong case
                 # (added since windows does not distinguish between e.g.
--- a/MoinMoin/auth/sslclientcert.py	Sun Oct 08 17:50:03 2006 +0200
+++ b/MoinMoin/auth/sslclientcert.py	Sun Oct 08 20:00:21 2006 +0200
@@ -10,7 +10,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-from MoinMoin import user
+from MoinMoin import config, user
 from MoinMoin.request import TWISTED
 
 def sslclientcert(request, **kw):
@@ -30,9 +30,9 @@
         if env.get('SSL_CLIENT_VERIFY', 'FAILURE') == 'SUCCESS':
             # if we only want to accept some specific CA, do a check like:
             # if env.get('SSL_CLIENT_I_DN_OU') == "http://www.cacert.org"
-            email = env.get('SSL_CLIENT_S_DN_Email', '')
+            email = env.get('SSL_CLIENT_S_DN_Email', '').decode(config.charset)
             email_lower = email.lower()
-            commonname = env.get('SSL_CLIENT_S_DN_CN', '')
+            commonname = env.get('SSL_CLIENT_S_DN_CN', '').decode(config.charset)
             commonname_lower = commonname.lower()
             if email_lower or commonname_lower:
                 for uid in user.getUserList(request):
--- a/MoinMoin/user.py	Sun Oct 08 17:50:03 2006 +0200
+++ b/MoinMoin/user.py	Sun Oct 08 20:00:21 2006 +0200
@@ -206,9 +206,9 @@
         @param request: the request object
         @param id: (optional) user ID
         @param name: (optional) user name
-        @param password: (optional) user password
+        @param password: (optional) user password (unicode)
         @param auth_username: (optional) already authenticated user name
-                              (e.g. when using http basic auth)
+                              (e.g. when using http basic auth) (unicode)
         @keyword auth_method: method that was used for authentication,
                               default: 'internal'
         @keyword auth_attribs: tuple of user object attribute names that are