changeset 4204:424800cd9596

Remove special cases of HTTP auth-handling, consolidate unto werkzeugs Authorization-object
author Florian Krupicka <florian.krupicka@googlemail.com>
date Wed, 09 Jul 2008 15:58:14 +0200
parents f4a92d2ee616
children 55e87dd68a22
files MoinMoin/auth/http.py
diffstat 1 files changed, 4 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/auth/http.py	Wed Jul 09 15:55:10 2008 +0200
+++ b/MoinMoin/auth/http.py	Wed Jul 09 15:58:14 2008 +0200
@@ -32,44 +32,10 @@
         if user_obj:
             return user_obj, True
 
-        # for standalone, request authorization and verify it,
-        # deny access if it isn't verified
-        if isinstance(request, request_standalone.Request):
-            request.www_authenticate.set_basic(realm="MoinMoin")
-            
-            auth = request.authorization
-            if auth:
-                u = user.User(request, auth_username=auth.username,
-                              password=auth.password,
-                              auth_method=self.name, auth_attribs=[])
-            if not u:
-                request.makeForbidden(401, _('You need to log in.'))
-        # for Twisted, just check
-        elif isinstance(request, request_twisted.Request):
-            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,
-                          auth_method=self.name, auth_attribs=())
-        elif not isinstance(request, request_cli.Request):
-            env = request.env
-            auth_type = env.get('AUTH_TYPE', '')
-            if auth_type in ['Basic', 'Digest', 'NTLM', 'Negotiate', ]:
-                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.
-                    #  "Mike" and "mike")
-                    username = username.split('\\')[-1] # split off domain e.g.
-                                                        # from DOMAIN\user
-                    # this "normalizes" the login name from {meier, Meier, MEIER} to Meier
-                    # put a comment sign in front of next line if you don't want that:
-                    username = username.title()
-                # when using http auth, we have external user name and password,
-                # we don't use the moin user profile for those attributes.
-                u = user.User(request, auth_username=username,
-                              auth_method=self.name, auth_attribs=('name', 'password'))
+        authobj = request.authorization
+        if authobj:
+            u = user.User(request, auth_username=authobj.username,
+                          auth_method=self.name, auth_attribs=('name', 'password'))
 
         if u:
             u.create_or_update()