server vulm improovements

dev-linux
robo-bo 2 years ago
parent 0a9a62087d
commit 2232240a58

@ -83,6 +83,7 @@ def AuthenticateVerify(inRequest):
###################################### ######################################
#Way 1 - try to find AuthToken #Way 1 - try to find AuthToken
lCookies = cookies.SimpleCookie(inRequest.headers.get("Cookie", "")) lCookies = cookies.SimpleCookie(inRequest.headers.get("Cookie", ""))
global gSettingsDict
#pdb.set_trace() #pdb.set_trace()
if "AuthToken" in lCookies: if "AuthToken" in lCookies:
lCookieAuthToken = lCookies.get("AuthToken", "").value lCookieAuthToken = lCookies.get("AuthToken", "").value
@ -148,6 +149,7 @@ def AuthenticateBlock(inRequest):
def UserAccessCheckBefore(inMethod, inRequest): def UserAccessCheckBefore(inMethod, inRequest):
# Help def - Get access flag from dict # Help def - Get access flag from dict
#pdb.set_trace() #pdb.set_trace()
global gSettingsDict
def HelpGetFlag(inAccessRuleItem, inRequest, inGlobalDict, inAuthenticateDict): def HelpGetFlag(inAccessRuleItem, inRequest, inGlobalDict, inAuthenticateDict):
if "FlagAccess" in inAccessRuleItem: if "FlagAccess" in inAccessRuleItem:
return inAccessRuleItem["FlagAccess"] return inAccessRuleItem["FlagAccess"]
@ -262,6 +264,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
# Def to get hierarchy of the current user roles # Def to get hierarchy of the current user roles
# if return {} - all is available # if return {} - all is available
def UserRoleHierarchyGet(self): def UserRoleHierarchyGet(self):
global gSettingsDict
lDomainUpperStr = self.OpenRPA["Domain"].upper() lDomainUpperStr = self.OpenRPA["Domain"].upper()
lUserUpperStr = self.OpenRPA["User"].upper() lUserUpperStr = self.OpenRPA["User"].upper()
return gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("RuleDomainUserDict", {}).get((lDomainUpperStr, lUserUpperStr), {}).get("RoleHierarchyAllowedDict", {}) return gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("RuleDomainUserDict", {}).get((lDomainUpperStr, lUserUpperStr), {}).get("RoleHierarchyAllowedDict", {})
@ -269,6 +272,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
#Tech def #Tech def
#return {"headers":[],"body":"","statuscode":111} #return {"headers":[],"body":"","statuscode":111}
def URLItemCheckDo(self, inURLItem, inMethod, inOnlyFlagUACBool = False): def URLItemCheckDo(self, inURLItem, inMethod, inOnlyFlagUACBool = False):
global gSettingsDict
############################### ###############################
#Tech sub def - do item #Tech sub def - do item
################################ ################################
@ -427,6 +431,8 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
def do_GET(self): def do_GET(self):
try: try:
global gSettingsDict
self.settimeout(gSettingsDict["ServerDict"]["RequestTimeoutSecFloat"])
threading.current_thread().request = self threading.current_thread().request = self
self.OpenRPA = {} self.OpenRPA = {}
self.OpenRPA["AuthToken"] = None self.OpenRPA["AuthToken"] = None
@ -515,6 +521,8 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
# POST # POST
def do_POST(self): def do_POST(self):
try: try:
global gSettingsDict
self.settimeout(gSettingsDict["ServerDict"]["RequestTimeoutSecFloat"])
threading.current_thread().request = self threading.current_thread().request = self
lL = gSettingsDict["Logger"] lL = gSettingsDict["Logger"]
self.OpenRPA = {} self.OpenRPA = {}
@ -629,7 +637,6 @@ class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
"""Handle requests in a separate thread.""" """Handle requests in a separate thread."""
def finish_request(self, request, client_address): def finish_request(self, request, client_address):
try: try:
request.settimeout(gSettingsDict["ServerDict"]["RequestTimeoutSecFloat"])
# "super" can not be used because BaseServer is not created from object # "super" can not be used because BaseServer is not created from object
HTTPServer.finish_request(self, request, client_address) HTTPServer.finish_request(self, request, client_address)
except ConnectionResetError as e: except ConnectionResetError as e:
@ -649,6 +656,7 @@ class RobotDaemonServer(Thread):
# Update the global dict # Update the global dict
ServerSettings.SettingsUpdate(inGlobalDict) ServerSettings.SettingsUpdate(inGlobalDict)
def run(self): def run(self):
global gSettingsDict
lL = gSettingsDict.get("Logger",None) lL = gSettingsDict.get("Logger",None)
try: try:
lServerDict = gSettingsDict["ServerDict"]["ListenDict"][self.name] lServerDict = gSettingsDict["ServerDict"]["ListenDict"][self.name]

Loading…
Cancel
Save