summaryrefslogtreecommitdiffstats
path: root/Lib/CGIHTTPServer.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2004-08-29 16:53:26 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2004-08-29 16:53:26 (GMT)
commita28b3e6dfb399a6107b717d78bc81ef6be80f123 (patch)
tree8dc37e1fa59054017d6540deb9abce2b3edce557 /Lib/CGIHTTPServer.py
parent061f132898d3232420db1c00a5adde13647d7e21 (diff)
downloadcpython-a28b3e6dfb399a6107b717d78bc81ef6be80f123.zip
cpython-a28b3e6dfb399a6107b717d78bc81ef6be80f123.tar.gz
cpython-a28b3e6dfb399a6107b717d78bc81ef6be80f123.tar.bz2
Patch #727483: Add AUTH_TYPE and REMOTE_USER.
Diffstat (limited to 'Lib/CGIHTTPServer.py')
-rw-r--r--Lib/CGIHTTPServer.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py
index f7b7722..47a0e2c 100644
--- a/Lib/CGIHTTPServer.py
+++ b/Lib/CGIHTTPServer.py
@@ -153,8 +153,21 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
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