Orc Server minor fixes in RDP List generation

dev-linux
Ivan Maslov 4 years ago
parent 48f9b0960c
commit ed4909bd1d

@ -340,152 +340,160 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
# Write content as utf-8 data # Write content as utf-8 data
self.wfile.write(inResponseDict["Body"]) self.wfile.write(inResponseDict["Body"])
def do_GET(self): def do_GET(self):
self.OpenRPA = {} try:
self.OpenRPA["AuthToken"] = None self.OpenRPA = {}
self.OpenRPA["Domain"] = None self.OpenRPA["AuthToken"] = None
self.OpenRPA["User"] = None self.OpenRPA["Domain"] = None
self.OpenRPA["DefUserRoleAccessAsk"]=self.UserRoleAccessAsk # Alias for def self.OpenRPA["User"] = None
self.OpenRPA["DefUserRoleHierarchyGet"]=self.UserRoleHierarchyGet # Alias for def self.OpenRPA["DefUserRoleAccessAsk"]=self.UserRoleAccessAsk # Alias for def
# Prepare result dict self.OpenRPA["DefUserRoleHierarchyGet"]=self.UserRoleHierarchyGet # Alias for def
lResponseDict = {"Headers": {}, "SetCookies": {}, "Body": b"", "StatusCode": None} # Prepare result dict
self.OpenRPAResponseDict = lResponseDict lResponseDict = {"Headers": {}, "SetCookies": {}, "Body": b"", "StatusCode": None}
##################################### self.OpenRPAResponseDict = lResponseDict
#Do authentication #####################################
#Check if authentication is turned on #Do authentication
##################################### #Check if authentication is turned on
lFlagAccessUserBlock=False #####################################
lAuthenticateDict = {"Domain": "", "User": ""} lFlagAccessUserBlock=False
if gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("FlagCredentialsAsk", False): lAuthenticateDict = {"Domain": "", "User": ""}
lAuthenticateDict = AuthenticateVerify(self)
if not lAuthenticateDict["User"]:
lFlagAccessUserBlock=True
# Logging
# gSettingsDict["Logger"].info(f"HTTP request /. Domain: {lAuthenticateDict['Domain']}, User: {lAuthenticateDict['User']}")
if lFlagAccessUserBlock:
AuthenticateBlock(self)
#####################################
else:
#Check the user access (if flag)
####################################
lFlagUserAccess = True
#If need user authentication
if gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("FlagCredentialsAsk", False): if gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("FlagCredentialsAsk", False):
lFlagUserAccess = UserAccessCheckBefore("GET", self) lAuthenticateDict = AuthenticateVerify(self)
###################################### if not lAuthenticateDict["User"]:
if lFlagUserAccess: lFlagAccessUserBlock=True
lOrchestratorFolder = "\\".join(__file__.split("\\")[:-1]) # Logging
############################ # gSettingsDict["Logger"].info(f"HTTP request /. Domain: {lAuthenticateDict['Domain']}, User: {lAuthenticateDict['User']}")
#New server engine (url from global dict (URLList)) if lFlagAccessUserBlock:
############################ AuthenticateBlock(self)
for lURLItem in gSettingsDict["ServerDict"]["URLList"]: #####################################
#Check if all condition are applied else:
lFlagURLIsApplied=False #Check the user access (if flag)
lFlagURLIsApplied=self.URLItemCheckDo(lURLItem, "GET") ####################################
if lFlagURLIsApplied: lFlagUserAccess = True
self.ResponseDictSend() #If need user authentication
return if gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("FlagCredentialsAsk", False):
#Monitor lFlagUserAccess = UserAccessCheckBefore("GET", self)
if self.path == '/Monitor/JSONDaemonListGet': ######################################
if lFlagUserAccess:
lOrchestratorFolder = "\\".join(__file__.split("\\")[:-1])
############################
#New server engine (url from global dict (URLList))
############################
for lURLItem in gSettingsDict["ServerDict"]["URLList"]:
#Check if all condition are applied
lFlagURLIsApplied=False
lFlagURLIsApplied=self.URLItemCheckDo(lURLItem, "GET")
if lFlagURLIsApplied:
self.ResponseDictSend()
return
#Monitor
if self.path == '/Monitor/JSONDaemonListGet':
# Send response status code
self.send_response(200)
# Send headers
self.send_header('Content-type','application/json')
self.end_headers()
# Send message back to client
message = json.dumps(gSettingsDict)
# Write content as utf-8 data
self.wfile.write(bytes(message, "utf8"))
#Filemanager function
if self.path.lower().startswith('/filemanager/'):
lFileURL=self.path[13:]
# check if file in FileURL - File Path Mapping Dict
if lFileURL.lower() in gSettingsDict["FileManager"]["FileURLFilePathDict"]:
self.SendResponseContentTypeFile('application/octet-stream', gSettingsDict["FileManager"]["FileURLFilePathDict"][lFileURL])
else:
#Set access denied code
# Send response status code # Send response status code
self.send_response(200) self.send_response(403)
# Send headers # Send headers
self.send_header('Content-type','application/json')
self.end_headers() self.end_headers()
# Send message back to client except Exception as e:
message = json.dumps(gSettingsDict) lL = gSettingsDict["Logger"]
# Write content as utf-8 data if lL: lL.exception(f"Server.do_GET: Global error handler - look traceback below.")
self.wfile.write(bytes(message, "utf8"))
#Filemanager function
if self.path.lower().startswith('/filemanager/'):
lFileURL=self.path[13:]
# check if file in FileURL - File Path Mapping Dict
if lFileURL.lower() in gSettingsDict["FileManager"]["FileURLFilePathDict"]:
self.SendResponseContentTypeFile('application/octet-stream', gSettingsDict["FileManager"]["FileURLFilePathDict"][lFileURL])
else:
#Set access denied code
# Send response status code
self.send_response(403)
# Send headers
self.end_headers()
# POST # POST
def do_POST(self): def do_POST(self):
lL = gSettingsDict["Logger"] try:
self.OpenRPA = {} lL = gSettingsDict["Logger"]
self.OpenRPA["AuthToken"] = None self.OpenRPA = {}
self.OpenRPA["Domain"] = None self.OpenRPA["AuthToken"] = None
self.OpenRPA["User"] = None self.OpenRPA["Domain"] = None
self.OpenRPA["DefUserRoleAccessAsk"]=self.UserRoleAccessAsk # Alias for def self.OpenRPA["User"] = None
self.OpenRPA["DefUserRoleHierarchyGet"]=self.UserRoleHierarchyGet # Alias for def self.OpenRPA["DefUserRoleAccessAsk"]=self.UserRoleAccessAsk # Alias for def
# Prepare result dict self.OpenRPA["DefUserRoleHierarchyGet"]=self.UserRoleHierarchyGet # Alias for def
#pdb.set_trace() # Prepare result dict
lResponseDict = {"Headers": {}, "SetCookies":{}, "Body": b"", "StatusCode": None} #pdb.set_trace()
self.OpenRPAResponseDict = lResponseDict lResponseDict = {"Headers": {}, "SetCookies":{}, "Body": b"", "StatusCode": None}
##################################### self.OpenRPAResponseDict = lResponseDict
#Do authentication #####################################
#Check if authentication is turned on #Do authentication
##################################### #Check if authentication is turned on
lFlagAccessUserBlock=False #####################################
lAuthenticateDict = {"Domain": "", "User": ""} lFlagAccessUserBlock=False
lIsSuperToken = False # Is supertoken lAuthenticateDict = {"Domain": "", "User": ""}
if gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("FlagCredentialsAsk", False): lIsSuperToken = False # Is supertoken
lAuthenticateDict = AuthenticateVerify(self)
# Get Flag is supertoken (True|False)
lIsSuperToken = gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("AuthTokensDict", {}).get(
self.OpenRPA["AuthToken"], {}).get("FlagDoNotExpire", False)
if not lAuthenticateDict["User"]:
lFlagAccessUserBlock=True
if lFlagAccessUserBlock:
AuthenticateBlock(self)
#####################################
else:
#Check the user access (if flag)
####################################
lFlagUserAccess = True
#If need user authentication
if gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("FlagCredentialsAsk", False): if gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("FlagCredentialsAsk", False):
lFlagUserAccess = UserAccessCheckBefore("POST", self) lAuthenticateDict = AuthenticateVerify(self)
###################################### # Get Flag is supertoken (True|False)
if lFlagUserAccess: lIsSuperToken = gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("AuthTokensDict", {}).get(
lOrchestratorFolder = "\\".join(__file__.split("\\")[:-1]) self.OpenRPA["AuthToken"], {}).get("FlagDoNotExpire", False)
############################ if not lAuthenticateDict["User"]:
#New server engine (url from global dict (URLList)) lFlagAccessUserBlock=True
############################ if lFlagAccessUserBlock:
for lURLItem in gSettingsDict["ServerDict"]["URLList"]: AuthenticateBlock(self)
#Check if all condition are applied #####################################
lFlagURLIsApplied=False else:
lFlagURLIsApplied=self.URLItemCheckDo(lURLItem, "POST") #Check the user access (if flag)
if lFlagURLIsApplied: ####################################
self.ResponseDictSend() lFlagUserAccess = True
return #If need user authentication
#Централизованная функция получения запросов/отправки if gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("FlagCredentialsAsk", False):
if self.path == '/Utils/Processor': lFlagUserAccess = UserAccessCheckBefore("POST", self)
#ReadRequest ######################################
lInputObject={} if lFlagUserAccess:
if self.headers.get('Content-Length') is not None: lOrchestratorFolder = "\\".join(__file__.split("\\")[:-1])
lInputByteArrayLength = int(self.headers.get('Content-Length')) ############################
lInputByteArray=self.rfile.read(lInputByteArrayLength) #New server engine (url from global dict (URLList))
#Превращение массива байт в объект ############################
lInputObject=json.loads(lInputByteArray.decode('utf8')) for lURLItem in gSettingsDict["ServerDict"]["URLList"]:
#Check if all condition are applied
lFlagURLIsApplied=False
lFlagURLIsApplied=self.URLItemCheckDo(lURLItem, "POST")
if lFlagURLIsApplied:
self.ResponseDictSend()
return
#Централизованная функция получения запросов/отправки
if self.path == '/Utils/Processor':
#ReadRequest
lInputObject={}
if self.headers.get('Content-Length') is not None:
lInputByteArrayLength = int(self.headers.get('Content-Length'))
lInputByteArray=self.rfile.read(lInputByteArrayLength)
#Превращение массива байт в объект
lInputObject=json.loads(lInputByteArray.decode('utf8'))
# Send response status code
self.send_response(200)
# Send headers
self.send_header('Content-type','application/json')
self.end_headers()
# Logging info about processor activity if not SuperToken ()
if not lIsSuperToken:
if lL: lL.info(f"Server:: User activity from web. Domain: {self.OpenRPA['Domain']}, Username: {self.OpenRPA['User']}, Activity: {lInputObject}")
# Send message back to client
message = json.dumps(ProcessorOld.ActivityListOrDict(lInputObject))
# Write content as utf-8 data
self.wfile.write(bytes(message, "utf8"))
return
else:
#Set access denied code
# Send response status code # Send response status code
self.send_response(200) self.send_response(403)
# Send headers # Send headers
self.send_header('Content-type','application/json')
self.end_headers() self.end_headers()
# Logging info about processor activity if not SuperToken () return
if not lIsSuperToken: except Exception as e:
if lL: lL.info(f"Server:: User activity from web. Domain: {self.OpenRPA['Domain']}, Username: {self.OpenRPA['User']}, Activity: {lInputObject}") lL = gSettingsDict["Logger"]
# Send message back to client if lL: lL.exception(f"Server.do_POST: Global error handler - look traceback below.")
message = json.dumps(ProcessorOld.ActivityListOrDict(lInputObject))
# Write content as utf-8 data
self.wfile.write(bytes(message, "utf8"))
return
else:
#Set access denied code
# Send response status code
self.send_response(403)
# Send headers
self.end_headers()
return
#Logging #Logging
#!Turn it on to stop print in console #!Turn it on to stop print in console
#def log_message(self, format, *args): #def log_message(self, format, *args):

@ -133,7 +133,7 @@ def HiddenRDPDictGenerate(inRequest, inGSettings):
lDataItemDict["IsFullScreenBool"] = True if lRDPSessionKeyStrItem == inGSettings["RobotRDPActive"][ lDataItemDict["IsFullScreenBool"] = True if lRDPSessionKeyStrItem == inGSettings["RobotRDPActive"][
"FullScreenRDPSessionKeyStr"] else False # Check the full screen for rdp window "FullScreenRDPSessionKeyStr"] else False # Check the full screen for rdp window
lDataItemDict["IsIgnoredBool"] = lRDPConfiguration["SessionIsIgnoredBool"] # Is ignored lDataItemDict["IsIgnoredBool"] = lRDPConfiguration["SessionIsIgnoredBool"] # Is ignored
lRDPDict[lDataItemDict["SessionKeyStr"]].append(lDataItemDict) lRDPDict[lDataItemDict["SessionKeyStr"]]=lDataItemDict
lHandlebarsDataItemDict = copy.deepcopy(lDataItemDict) lHandlebarsDataItemDict = copy.deepcopy(lDataItemDict)
lHandlebarsDataItemDict["SessionKeyStr"]=lDataItemDict["SessionKeyStr"] lHandlebarsDataItemDict["SessionKeyStr"]=lDataItemDict["SessionKeyStr"]
lRDPDict["HandlebarsList"].append(lHandlebarsDataItemDict) lRDPDict["HandlebarsList"].append(lHandlebarsDataItemDict)

Loading…
Cancel
Save