[Python-checkins] python/dist/src/Lib CGIHTTPServer.py,1.35,1.36

loewis at users.sourceforge.net loewis at users.sourceforge.net
Sun Aug 29 18:53:29 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26279/Lib

Modified Files:
	CGIHTTPServer.py 
Log Message:
Patch #727483: Add AUTH_TYPE and REMOTE_USER.


Index: CGIHTTPServer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/CGIHTTPServer.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- CGIHTTPServer.py	20 Mar 2004 22:18:03 -0000	1.35
+++ CGIHTTPServer.py	29 Aug 2004 16:53:26 -0000	1.36
@@ -153,8 +153,21 @@
         if host != self.client_address[0]:
             env['REMOTE_HOST'] = host
         env['REMOTE_ADDR'] = self.client_address[0]
-        # XXX AUTH_TYPE
-        # XXX REMOTE_USER
+        authorization = self.headers.getheader("authorization")
+        if authorization:
+            authorization = authorization.split()
+            if len(authorization) == 2:
+                import base64, binascii
+                env['AUTH_TYPE'] = authorization[0]
+                if authorization[0].lower() == "basic":
+                    try:
+                        authorization = base64.decodestring(authorization[1])
+                    except binascii.Error:
+                        pass
+                    else:
+                        authorization = authorization.split(':')
+                        if len(authorization) == 2:
+                            env['REMOTE_USER'] = authorization[0]
         # XXX REMOTE_IDENT
         if self.headers.typeheader is None:
             env['CONTENT_TYPE'] = self.headers.type



More information about the Python-checkins mailing list