[IMP] service: pass db parameter in checkRequest for http
bzr revid: hmo@tinyerp.com-20100406110953-5x0h9b3jlytnkty6
This commit is contained in:
parent
e92975499f
commit
8326caf5de
|
@ -251,12 +251,11 @@ class OerpAuthProxy(AuthProxy):
|
||||||
self.auth_tries = 0
|
self.auth_tries = 0
|
||||||
self.last_auth = None
|
self.last_auth = None
|
||||||
|
|
||||||
def checkRequest(self,handler,path = '/'):
|
def checkRequest(self,handler,path, db=False):
|
||||||
if self.auth_creds:
|
|
||||||
return True
|
|
||||||
auth_str = handler.headers.get('Authorization',False)
|
auth_str = handler.headers.get('Authorization',False)
|
||||||
try:
|
try:
|
||||||
db = handler.get_db_from_path(path)
|
if not db:
|
||||||
|
db = handler.get_db_from_path(path)
|
||||||
print "Got db:",db
|
print "Got db:",db
|
||||||
except:
|
except:
|
||||||
if path.startswith('/'):
|
if path.startswith('/'):
|
||||||
|
@ -267,8 +266,9 @@ class OerpAuthProxy(AuthProxy):
|
||||||
else:
|
else:
|
||||||
#FIXME!
|
#FIXME!
|
||||||
self.provider.log("Wrong path: %s, failing auth" %path)
|
self.provider.log("Wrong path: %s, failing auth" %path)
|
||||||
raise AuthRejectedExc("Authorization failed. Wrong sub-path.")
|
raise AuthRejectedExc("Authorization failed. Wrong sub-path.")
|
||||||
|
if self.auth_creds.get(db):
|
||||||
|
return True
|
||||||
if auth_str and auth_str.startswith('Basic '):
|
if auth_str and auth_str.startswith('Basic '):
|
||||||
auth_str=auth_str[len('Basic '):]
|
auth_str=auth_str[len('Basic '):]
|
||||||
(user,passwd) = base64.decodestring(auth_str).split(':')
|
(user,passwd) = base64.decodestring(auth_str).split(':')
|
||||||
|
@ -276,7 +276,7 @@ class OerpAuthProxy(AuthProxy):
|
||||||
acd = self.provider.authenticate(db,user,passwd,handler.client_address)
|
acd = self.provider.authenticate(db,user,passwd,handler.client_address)
|
||||||
if acd != False:
|
if acd != False:
|
||||||
self.auth_creds[db] = acd
|
self.auth_creds[db] = acd
|
||||||
self.last_auth=db
|
self.last_auth = db
|
||||||
return True
|
return True
|
||||||
if self.auth_tries > 5:
|
if self.auth_tries > 5:
|
||||||
self.provider.log("Failing authorization after 5 requests w/o password")
|
self.provider.log("Failing authorization after 5 requests w/o password")
|
||||||
|
|
|
@ -234,6 +234,9 @@ class MultiHTTPHandler(FixSendError,BaseHTTPRequestHandler):
|
||||||
if fore.close_connection:
|
if fore.close_connection:
|
||||||
# print "Closing connection because of handler"
|
# print "Closing connection because of handler"
|
||||||
self.close_connection = fore.close_connection
|
self.close_connection = fore.close_connection
|
||||||
|
if hasattr(fore, '_flush'):
|
||||||
|
fore._flush()
|
||||||
|
|
||||||
|
|
||||||
def parse_rawline(self):
|
def parse_rawline(self):
|
||||||
"""Parse a request (internal).
|
"""Parse a request (internal).
|
||||||
|
|
Loading…
Reference in New Issue