/usr/share/pyshared/ZSI/auth.py is in python-zsi 2.1~a1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # $Header$
'''Simple CGI dispatching.
'''
from ZSI import *
from ZSI import _copyright
import base64, os
_b64_decode = base64.decodestring
# Typecode to parse a ZSI BasicAuth header.
_auth_tc = TC.Struct(None,
[ TC.String('Name'), TC.String('Password') ],
extras=1)
class AUTH:
'''Constants for authentication mechanisms.
'''
none = 0
httpbasic = 1
zsibasic = 2
httpdigest = 4
class ClientBinding:
'''Information about the client that is connected to us.
'''
def __init__(self, ps):
self.ps, self.auth = \
ps, None
self.environ = os.environ.copy()
self.environ['CONTENT_LENGTH'] = str(0)
def GetAuth(self):
'''Return a tuple containing client authentication data.
'''
if self.auth: return self.auth
for elt in self.ps.GetMyHeaderElements():
if elt.localName == 'BasicAuth' \
and elt.namespaceURI == ZSI_SCHEMA_URI:
d = _auth_tc.parse(elt, self.ps)
self.auth = (AUTH.zsibasic, d['Name'], d['Password'])
return self.auth
ba = self.environ.get('HTTP_AUTHENTICATION')
if ba:
ba = ba.split(' ')
if len(ba) == 2 and ba[0].lower() == 'basic':
ba = _b64_decode(ba[1])
self.auth = (AUTH.httpbasic,) + tuple(ba.split(':'))
return self.auth
self.auth = (AUTH.none,)
return self.auth
def GetNS(self):
'''Return namespace for the top main request element.
'''
return self.ps.body_root.namespaceURI or ''
def GetRequest(self):
'''Return the ParsedSoap request.
'''
return self.ps
if __name__ == '__main__': print _copyright
|