Add UACBool in URLList - user with no access can use orchestrator!

dev-linux
Ivan Maslov 3 years ago
parent 6bb4ce0660
commit 0eeb209520

@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 4
}

@ -0,0 +1,64 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def t(*in_arg_list):\n",
" for l_item in in_arg_list:\n",
" print(l_item)\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n",
"2\n",
"1\n"
]
}
],
"source": [
"t(3,2,1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

@ -526,3 +526,10 @@ def Update(inGSettings):
inGSettings["ProcessorDict"]["ActivityItemNowDict"]=None inGSettings["ProcessorDict"]["ActivityItemNowDict"]=None
if lL: lL.warning( if lL: lL.warning(
f"Backward compatibility (v1.2.4 to v1.2.7): Create new key: ProcessorDict > ActivityItemNowDict") # Log about compatibility f"Backward compatibility (v1.2.4 to v1.2.7): Create new key: ProcessorDict > ActivityItemNowDict") # Log about compatibility
# # "UACBool": True # True - check user access before do this URL item
for lURLItemDict in inGSettings["ServerDict"]["URLList"]:
if "UACBool" not in lURLItemDict:
lURLItemDict["UACBool"]=None
if lL: lL.warning(
f"Backward compatibility (v1.2.4 to v1.2.7): ServerDict > URLList > item: add UACBool = None") # Log about compatibility

@ -261,7 +261,7 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
#Tech def #Tech def
#return {"headers":[],"body":"","statuscode":111} #return {"headers":[],"body":"","statuscode":111}
def URLItemCheckDo(self, inURLItem, inMethod): def URLItemCheckDo(self, inURLItem, inMethod, inOnlyFlagUACBool = False):
############################### ###############################
#Tech sub def - do item #Tech sub def - do item
################################ ################################
@ -305,6 +305,9 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
# Закрыть файловый объект # Закрыть файловый объект
lFileObject.close() lFileObject.close()
############################################## ##############################################
# UAC Check
if inOnlyFlagUACBool == True and inURLItem.get("UACBool",None) in [None, False]:
return False
if inURLItem["Method"].upper() == inMethod.upper(): if inURLItem["Method"].upper() == inMethod.upper():
# check Match type variant: BeginWith # check Match type variant: BeginWith
if inURLItem["MatchType"].upper() == "BEGINWITH": if inURLItem["MatchType"].upper() == "BEGINWITH":
@ -378,6 +381,16 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
# Prepare result dict # Prepare result dict
lResponseDict = {"Headers": {}, "SetCookies": {}, "Body": b"", "StatusCode": None} lResponseDict = {"Headers": {}, "SetCookies": {}, "Body": b"", "StatusCode": None}
self.OpenRPAResponseDict = lResponseDict self.OpenRPAResponseDict = lResponseDict
############################
#First - all with Flag UACBool
############################
for lURLItem in gSettingsDict["ServerDict"]["URLList"]:
#Check if all condition are applied
lFlagURLIsApplied=False
lFlagURLIsApplied=self.URLItemCheckDo(inURLItem=lURLItem, inMethod="GET", inOnlyFlagUACBool=True)
if lFlagURLIsApplied:
self.ResponseDictSend()
return
##################################### #####################################
#Do authentication #Do authentication
#Check if authentication is turned on #Check if authentication is turned on
@ -454,6 +467,16 @@ class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
#pdb.set_trace() #pdb.set_trace()
lResponseDict = {"Headers": {}, "SetCookies":{}, "Body": b"", "StatusCode": None} lResponseDict = {"Headers": {}, "SetCookies":{}, "Body": b"", "StatusCode": None}
self.OpenRPAResponseDict = lResponseDict self.OpenRPAResponseDict = lResponseDict
############################
#First - all with Flag UACBool
############################
for lURLItem in gSettingsDict["ServerDict"]["URLList"]:
#Check if all condition are applied
lFlagURLIsApplied=False
lFlagURLIsApplied=self.URLItemCheckDo(inURLItem=lURLItem, inMethod="POST", inOnlyFlagUACBool=True)
if lFlagURLIsApplied:
self.ResponseDictSend()
return
##################################### #####################################
#Do authentication #Do authentication
#Check if authentication is turned on #Check if authentication is turned on

@ -109,7 +109,8 @@ def __Create__():
# "ResponseFilePath": "", #Absolute or relative path # "ResponseFilePath": "", #Absolute or relative path
# "ResponseFolderPath": "", #Absolute or relative path # "ResponseFolderPath": "", #Absolute or relative path
# "ResponseContentType": "", #HTTP Content-type # "ResponseContentType": "", #HTTP Content-type
# "ResponseDefRequestGlobal": None #Function with str result # "ResponseDefRequestGlobal": None ,#Function with str result
# "UACBool": True # True - check user access before do this URL item. None - get Server flag if ask user
# } # }
{ {
"Method": "GET", "Method": "GET",
@ -120,6 +121,7 @@ def __Create__():
# Absolute or relative path # Absolute or relative path
# "ResponseContentType": "", #HTTP Content-type # "ResponseContentType": "", #HTTP Content-type
# "ResponseDefRequestGlobal": None #Function with str result # "ResponseDefRequestGlobal": None #Function with str result
# "UACBool": True # True - check user access before do this URL item
} }
], ],

@ -842,7 +842,7 @@ def UACSuperTokenUpdate(inSuperTokenStr, inGSettings=None):
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def WebURLConnectDef(inMethodStr, inURLStr, inMatchTypeStr, inDef, inContentTypeStr="application/octet-stream", inGSettings = None): def WebURLConnectDef(inMethodStr, inURLStr, inMatchTypeStr, inDef, inContentTypeStr="application/octet-stream", inGSettings = None, inUACBool = None):
""" """
Connect URL to DEF Connect URL to DEF
"inMethodStr":"GET|POST", "inMethodStr":"GET|POST",
@ -857,6 +857,7 @@ def WebURLConnectDef(inMethodStr, inURLStr, inMatchTypeStr, inDef, inContentType
:param inMatchTypeStr: #"BeginWith|Contains|Equal|EqualCase", :param inMatchTypeStr: #"BeginWith|Contains|Equal|EqualCase",
:param inDef: def arg allowed list: 2:[inRequest, inGSettings], 1: [inRequest], 0: [] :param inDef: def arg allowed list: 2:[inRequest, inGSettings], 1: [inRequest], 0: []
:param inContentTypeStr: default: "application/octet-stream" :param inContentTypeStr: default: "application/octet-stream"
:param inUACBool: default: None; True - check user access before do this URL item. None - get Server flag if ask user
""" """
inGSettings = GSettingsGet(inGSettings=inGSettings) # Set the global settings inGSettings = GSettingsGet(inGSettings=inGSettings) # Set the global settings
lURLItemDict = { lURLItemDict = {
@ -867,24 +868,27 @@ def WebURLConnectDef(inMethodStr, inURLStr, inMatchTypeStr, inDef, inContentType
#"ResponseFolderPath": "C:\Abs\Archive\scopeSrcUL\OpenRPA\Orchestrator\Settings", #"ResponseFolderPath": "C:\Abs\Archive\scopeSrcUL\OpenRPA\Orchestrator\Settings",
# Absolute or relative path # Absolute or relative path
"ResponseContentType": inContentTypeStr, #HTTP Content-type "ResponseContentType": inContentTypeStr, #HTTP Content-type
"ResponseDefRequestGlobal": inDef #Function with str result "ResponseDefRequestGlobal": inDef, #Function with str result
"UACBool": inUACBool
} }
inGSettings["ServerDict"]["URLList"].append(lURLItemDict) inGSettings["ServerDict"]["URLList"].append(lURLItemDict)
def WebURLConnectFolder(inMethodStr, inURLStr, inMatchTypeStr, inFolderPathStr, inGSettings = None): def WebURLConnectFolder(inMethodStr, inURLStr, inMatchTypeStr, inFolderPathStr, inGSettings = None, inUACBool = None):
""" """
Connect URL to Folder Connect URL to Folder
"inMethodStr":"GET|POST", "inMethodStr":"GET|POST",
"inURLStr": "/Folder/", #URL of the request "inURLStr": "/Folder/", #URL of the request
"inMatchTypeStr": "", #"BeginWith|Contains|Equal|EqualCase", "inMatchTypeStr": "", #"BeginWith|Contains|Equal|EqualCase",
"inFolderPathStr": "", #Absolute or relative path "inFolderPathStr": "", #Absolute or relative path
"inUACBool"
:param inGSettings: Global settings dict (singleton) :param inGSettings: Global settings dict (singleton)
:param inMethodStr: :param inMethodStr:
:param inURLStr: :param inURLStr:
:param inMatchTypeStr: :param inMatchTypeStr:
:param inFolderPathStr: :param inFolderPathStr:
:param inUACBool: default: None; True - check user access before do this URL item. None - get Server flag if ask user
""" """
inGSettings = GSettingsGet(inGSettings=inGSettings) # Set the global settings inGSettings = GSettingsGet(inGSettings=inGSettings) # Set the global settings
# Check if last symbol is "/" - append if not exist # Check if last symbol is "/" - append if not exist
@ -899,11 +903,12 @@ def WebURLConnectFolder(inMethodStr, inURLStr, inMatchTypeStr, inFolderPathStr,
"ResponseFolderPath": lFolderPathStr, # Absolute or relative path "ResponseFolderPath": lFolderPathStr, # Absolute or relative path
"ResponseContentType": "application/octet-stream", #HTTP Content-type "ResponseContentType": "application/octet-stream", #HTTP Content-type
#"ResponseDefRequestGlobal": inDef #Function with str result #"ResponseDefRequestGlobal": inDef #Function with str result
"UACBool": inUACBool
} }
inGSettings["ServerDict"]["URLList"].append(lURLItemDict) inGSettings["ServerDict"]["URLList"].append(lURLItemDict)
def WebURLConnectFile(inMethodStr, inURLStr, inMatchTypeStr, inFilePathStr, inContentTypeStr="application/octet-stream", inGSettings = None): def WebURLConnectFile(inMethodStr, inURLStr, inMatchTypeStr, inFilePathStr, inContentTypeStr="application/octet-stream", inGSettings = None, inUACBool = None):
""" """
Connect URL to File Connect URL to File
"inMethodStr":"GET|POST", "inMethodStr":"GET|POST",
@ -917,6 +922,7 @@ def WebURLConnectFile(inMethodStr, inURLStr, inMatchTypeStr, inFilePathStr, inCo
:param inMatchTypeStr: :param inMatchTypeStr:
:param inFilePathStr: :param inFilePathStr:
:param inContentTypeStr: :param inContentTypeStr:
:param inUACBool: default: None; True - check user access before do this URL item. None - get Server flag if ask user
""" """
inGSettings = GSettingsGet(inGSettings=inGSettings) # Set the global settings inGSettings = GSettingsGet(inGSettings=inGSettings) # Set the global settings
lURLItemDict = { lURLItemDict = {
@ -927,6 +933,7 @@ def WebURLConnectFile(inMethodStr, inURLStr, inMatchTypeStr, inFilePathStr, inCo
#"ResponseFolderPath": os.path.abspath(inFilePathStr), # Absolute or relative path #"ResponseFolderPath": os.path.abspath(inFilePathStr), # Absolute or relative path
"ResponseContentType": inContentTypeStr, #HTTP Content-type "ResponseContentType": inContentTypeStr, #HTTP Content-type
#"ResponseDefRequestGlobal": inDef #Function with str result #"ResponseDefRequestGlobal": inDef #Function with str result
"UACBool":inUACBool
} }
inGSettings["ServerDict"]["URLList"].append(lURLItemDict) inGSettings["ServerDict"]["URLList"].append(lURLItemDict)

Loading…
Cancel
Save