def authenticate_client(self):
validuser = False
if self.headers.has_key('Authorization'):
# handle Basic authentication
(enctype, encstr) = self.headers.get('Authorization').split()
(emailid, machine_name) = base64.standard_b64decode(encstr).split(':')
(auth_machine, auth_uuidstr, auth_email) = authenticate(machine_name)
if emailid == auth_email:
print "Authenticated"
# set authentication cookies on client machines
validuser = True
if auth_uuidstr:
self.setCookie('UUID',auth_uuidstr)
elif self.headers.has_key('UUID'):
# handle cookie based authentication
id = self.headers.get('UUID')
(auth_machine, auth_uuidstr, auth_email) = authenticate(id)
if auth_uuidstr :
print "Authenticated"
validuser = True
else:
print 'Authentication failed'
return validuser
评论列表
文章目录