File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,8 +153,21 @@ def run_cgi(self):
153153 if host != self .client_address [0 ]:
154154 env ['REMOTE_HOST' ] = host
155155 env ['REMOTE_ADDR' ] = self .client_address [0 ]
156- # XXX AUTH_TYPE
157- # XXX REMOTE_USER
156+ authorization = self .headers .getheader ("authorization" )
157+ if authorization :
158+ authorization = authorization .split ()
159+ if len (authorization ) == 2 :
160+ import base64 , binascii
161+ env ['AUTH_TYPE' ] = authorization [0 ]
162+ if authorization [0 ].lower () == "basic" :
163+ try :
164+ authorization = base64 .decodestring (authorization [1 ])
165+ except binascii .Error :
166+ pass
167+ else :
168+ authorization = authorization .split (':' )
169+ if len (authorization ) == 2 :
170+ env ['REMOTE_USER' ] = authorization [0 ]
158171 # XXX REMOTE_IDENT
159172 if self .headers .typeheader is None :
160173 env ['CONTENT_TYPE' ] = self .headers .type
You can’t perform that action at this time.
0 commit comments