From caeae7c99750b0f72b3c67fe9079d879c60fcb04 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Sat, 5 Dec 2020 09:48:12 +0300 Subject: [PATCH] - Create new pyOpenRPA UAC Client hierarchy SettingsTemplate.__UACClientAdminCreate__ - need to update functionallity - Orchestrator WEB: Update WEB to the new UACClient --- Orchestrator/OrchestratorSettings.py | 17 +++++- .../pyOpenRPA/Orchestrator/Orchestrator.py | 6 +- .../pyOpenRPA/Orchestrator/ServerSettings.py | 2 +- .../Orchestrator/SettingsTemplate.py | 38 +++++++++++++ Sources/pyOpenRPA/Orchestrator/Web/Index.js | 56 +++++++------------ .../pyOpenRPA/Orchestrator/Web/Index.xhtml | 22 ++++---- changelog.md | 8 ++- 7 files changed, 92 insertions(+), 57 deletions(-) diff --git a/Orchestrator/OrchestratorSettings.py b/Orchestrator/OrchestratorSettings.py index f5ccf58d..bfa2928b 100644 --- a/Orchestrator/OrchestratorSettings.py +++ b/Orchestrator/OrchestratorSettings.py @@ -23,16 +23,27 @@ if lPyOpenRPASourceFolderPathStr != "": sys.path.insert(0,os.path.abspath(os.pat # Start import after config the pyOpenRPA folder from pyOpenRPA.Orchestrator import SettingsTemplate # Import functionallity + if __name__ == "__main__": # New init way - allow run as module -m PyOpenRPA.Orchestrator from pyOpenRPA.Orchestrator import Orchestrator # Import orchestrator main gSettings = SettingsTemplate.Create(inModeStr="BASIC") # Create GSettings with basic configuration # TEST Add User ND - Add Login ND to superuser of the Orchestrator - Orchestrator.OrchestratorAccessUserUpdate(inGSettings=gSettings, inADLoginStr="ND", inADStr="", inADIsDefaultBool=True, inURLList=[],inCPAllowKeyList=[]) + lUACClientDict = SettingsTemplate.__UACClientAdminCreate__() + # del lUACClientDict["pyOpenRPADict"]["AdminDict"]["LogViewerBool"] + # del lUACClientDict["pyOpenRPADict"]["AdminDict"]["CMDInputBool"] + # del lUACClientDict["pyOpenRPADict"]["AdminDict"]["ScreenshotViewerBool"] + # del lUACClientDict["pyOpenRPADict"]["AdminDict"]["RestartOrchestratorBool"] + # del lUACClientDict["pyOpenRPADict"]["AdminDict"]["RestartOrchestratorGITPullBool"] + # del lUACClientDict["pyOpenRPADict"]["AdminDict"]["RestartPCBool"] + # del lUACClientDict["pyOpenRPADict"]["RDPKeyDict"] + # del lUACClientDict["pyOpenRPADict"]["AgentKeyDict"] + # del lUACClientDict["pyOpenRPADict"]["CPKeyDict"] + Orchestrator.OrchestratorUACUpdate(inGSettings=gSettings, inADLoginStr="ND", inADStr="", inADIsDefaultBool=True, inURLList=[], inCPAllowKeyList=[], inRoleHierarchyAllowedDict=lUACClientDict) # TEST Add User IMaslov - Add Login IMaslov to superuser of the Orchestrator - Orchestrator.OrchestratorAccessUserUpdate(inGSettings=gSettings, inADLoginStr="IMaslov", inADStr="", inADIsDefaultBool=True, inURLList=[],inCPAllowKeyList=[]) + Orchestrator.OrchestratorUACUpdate(inGSettings=gSettings, inADLoginStr="IMaslov", inADStr="", inADIsDefaultBool=True, inURLList=[], inCPAllowKeyList=[]) # TEST Add Supertoken for the all access between robots - Orchestrator.OrchestratorAccessSuperTokenAdd(inGSettings=gSettings, inSuperTokenStr="1992-04-03-0643-ru-b4ff-openrpa52zzz") + Orchestrator.OrchestratorUACSuperTokenUpdate(inGSettings=gSettings, inSuperTokenStr="1992-04-03-0643-ru-b4ff-openrpa52zzz") ## !!! For Relative import !!! CP Version Check sys.path.insert(0,os.path.abspath(os.path.join(r""))) diff --git a/Sources/pyOpenRPA/Orchestrator/Orchestrator.py b/Sources/pyOpenRPA/Orchestrator/Orchestrator.py index b6a4f24d..9b0902a2 100644 --- a/Sources/pyOpenRPA/Orchestrator/Orchestrator.py +++ b/Sources/pyOpenRPA/Orchestrator/Orchestrator.py @@ -88,7 +88,7 @@ def OrchestratorSessionSave(inGSettings=None): ## Orchestrator session save f"Orchestrator has dump the RDP list before the restart. The RDP List is {inGSettings['RobotRDPActive']['RDPList']}") return True # Update user access -def OrchestratorAccessUserUpdate(inGSettings, inADLoginStr, inADStr="", inADIsDefaultBool=True, inURLList=[], inCPAllowKeyList=[], inRoleHierarchyAllowedDict={}): +def OrchestratorUACUpdate(inGSettings, inADLoginStr, inADStr="", inADIsDefaultBool=True, inURLList=[], inCPAllowKeyList=[], inRoleHierarchyAllowedDict={}): # Backward compatibility if inURLList==[]: inURLList=[ @@ -120,9 +120,9 @@ def OrchestratorAccessUserUpdate(inGSettings, inADLoginStr, inADStr="", inADIsDe inGSettings["Server"]["AccessUsers"]["RuleDomainUserDict"].update({("",inADLoginStr.upper()):lRuleDomainUserDict}) # Add supertoken for the all access (it is need for the robot communication without human) -def OrchestratorAccessSuperTokenAdd(inGSettings, inSuperTokenStr): +def OrchestratorUACSuperTokenUpdate(inGSettings, inSuperTokenStr): lLoginStr = "SUPERTOKEN" - OrchestratorAccessUserUpdate(inGSettings=inGSettings, inADLoginStr=lLoginStr) + OrchestratorUACUpdate(inGSettings=inGSettings, inADLoginStr=lLoginStr) inGSettings["Server"]["AccessUsers"]["AuthTokensDict"].update( {inSuperTokenStr:{"User":lLoginStr, "Domain":"", "TokenDatetime": datetime.datetime.now(), "FlagDoNotExpire":True}} ) diff --git a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py index a6965ddc..fdb1b037 100644 --- a/Sources/pyOpenRPA/Orchestrator/ServerSettings.py +++ b/Sources/pyOpenRPA/Orchestrator/ServerSettings.py @@ -90,7 +90,7 @@ def pyOpenRPA_ServerData(inRequest,inGSettings): lServerDataDict = { "CPDict": HiddenCPDictGenerate(inRequest=inRequest, inGSettings=inGSettings), "RDPDict": HiddenRDPDictGenerate(inRequest=inRequest, inGSettings=inGSettings), - "UserDict": {"RoleHierarchyDict": inRequest.OpenRPA["DefUserRoleHierarchyGet"]()} + "UserDict": {"UACClientDict": inRequest.OpenRPA["DefUserRoleHierarchyGet"]()} } # Create JSON lServerDataDictJSONStr = json.dumps(lServerDataDict) diff --git a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py index d3b4f6b5..cd16a728 100644 --- a/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py +++ b/Sources/pyOpenRPA/Orchestrator/SettingsTemplate.py @@ -291,6 +291,44 @@ def __Create__(): } } +# Create full configuration for +def __UACClientAdminCreate__(): + lResultDict = { + "pyOpenRPADict":{ + "CPKeyDict":{ # Empty dict - all access + # "CPKeyStr"{ + # } + }, + "RDPKeyDict":{ # Empty dict - all access + #"RDPKeyStr"{ + # "FullscreenBool": True, + # "IgnoreBool":True, + # "ReconnectBool": True + # "NothingBool": True # USe option if you dont want to give some access to the RDP controls + # } + }, + "AgentKeyDict": { # Empty dict - all access + # "AgentKeyStr"{ + # } + }, + "AdminDict":{ # Empty dict - all access + "LogViewerBool":True, # Show log viewer on the web page + "CMDInputBool":True, # Execute CMD on the server side and result to the logs + "ScreenshotViewerBool":True, # Show button to look screenshots + "RestartOrchestratorBool": True, # Restart orchestrator activity + "RestartOrchestratorGITPullBool": True, # Turn off (RDP remember) orc + git pull + Turn on (rdp remember) + "RestartPCBool": True, # Send CMD to restart pc + "NothingBool":True # USe option if you dont want to give some access to the RDP controls + }, + "ActivityDict": { # Empty dict - all access + "ActivityListExecuteBool": True, # Execute activity at the current thread + "ActivityListAppendProcessorQueueBool": True # Append activity to the processor queue + } + } + + } + return lResultDict + # inModeStr: # "BASIC" - create standart configuration from pyOpenRPA.Orchestrator.Utils import LoggerHandlerDumpLogList diff --git a/Sources/pyOpenRPA/Orchestrator/Web/Index.js b/Sources/pyOpenRPA/Orchestrator/Web/Index.js index afa4d54c..b56e87c1 100644 --- a/Sources/pyOpenRPA/Orchestrator/Web/Index.js +++ b/Sources/pyOpenRPA/Orchestrator/Web/Index.js @@ -389,6 +389,7 @@ $(document).ready(function() { mGlobal.pyOpenRPA.ServerDataDict = lResponseJSON["ServerDataDict"] mGlobal.pyOpenRPA.ServerDataHashStr = lResponseJSON["HashStr"] mGlobal.pyOpenRPA.ServerDataRefreshDef_TechnicalRender() + mGlobal.UserRoleUpdate(); } catch(error) { } @@ -745,7 +746,7 @@ $(document).ready(function() { // UAC Ask mGlobal.UserRoleAsk=function(inList) { var lResult = true; // Init flag - var lRoleHierarchyDict = mGlobal.UserRoleHierarchyDict; // get the Hierarchy + var lRoleHierarchyDict = mGlobal.pyOpenRPA.ServerDataDict.UserDict.UACClientDict; // get the Hierarchy // Try to get value from key list var lKeyValue = lRoleHierarchyDict; // Init the base var lListLength = inList.length; @@ -771,42 +772,25 @@ $(document).ready(function() { } // Check user roles and update the Orchestrator UI mGlobal.UserRoleUpdate=function() { - $.ajax({ - type: "POST", - url: 'Orchestrator/UserRoleHierarchyGet', - data: "", - success: - function(lData,l2,l3) - { - var lUACAsk = mGlobal.UserRoleAsk // Alias - var lResponseDict=JSON.parse(lData) - mGlobal.UserRoleHierarchyDict = lResponseDict // set the user role hierarchy - //Turn on the Lookmachine screenshot button - if (lUACAsk(["Orchestrator","Controls","LookMachineScreenshots"])) { - $(".openrpa-control-lookmachinescreenshot").show() //Show button - } - //Turn on the restart orchestrator button - if (lUACAsk(["Orchestrator","Controls","RestartOrchestrator"])) { - $(".openrpa-control-restartorchestrator").show() //Show button - } - //Turn on the rdp session list - if (lUACAsk(["Orchestrator","RDPActive","ListRead"])) { - $(".openrpa-rdpactive-title").show() //Show section - $(".openrpa-robotrdpactive-control-panel-general").show() //Show section - } - //Turn on the restart PC button - if (lUACAsk(["Orchestrator","Controls","RestartPC"])) { - $(".openrpa-control-restartpc").show() //Show button - } - //Turn on the git update + restart orchestrator - if (lUACAsk(["Orchestrator","Controls","GITRestartOrchestrator"])) { - $(".openrpa-control-gitrestartorchestrator").show() //Show button - } - }, - dataType: "text" - }); + var lUACAsk = mGlobal.UserRoleAsk // Alias + //CPKeyDict + if (lUACAsk(["pyOpenRPADict","CPKeyDict"])) { $(".UACClient-pyOpenRPADict-CPKeyDict").show(); } + + //RDPKeyDict + if (lUACAsk(["pyOpenRPADict","RDPKeyDict"])) { $(".UACClient-pyOpenRPADict-RDPKeyDict").show(); } + + //AgentKeyDict + if (lUACAsk(["pyOpenRPADict","AgentKeyDict"])) { $(".UACClient-pyOpenRPADict-AgentKeyDict").show(); } + + // AdminDict + if (lUACAsk(["pyOpenRPADict","AdminDict","LogViewerBool"])) { $(".UACClient-pyOpenRPADict-AdminDict-LogViewerBool").show(); } + if (lUACAsk(["pyOpenRPADict","AdminDict","CMDInputBool"])) { $(".UACClient-pyOpenRPADict-AdminDict-CMDInputBool").show(); } + if (lUACAsk(["pyOpenRPADict","AdminDict","ScreenshotViewerBool"])) { $(".UACClient-pyOpenRPADict-AdminDict-ScreenshotViewerBool").show(); } + if (lUACAsk(["pyOpenRPADict","AdminDict","RestartOrchestratorBool"])) { $(".UACClient-pyOpenRPADict-AdminDict-RestartOrchestratorBool").show(); } + if (lUACAsk(["pyOpenRPADict","AdminDict","RestartOrchestratorGITPullBool"])) { $(".UACClient-pyOpenRPADict-AdminDict-RestartOrchestratorGITPullBool").show(); } + if (lUACAsk(["pyOpenRPADict","AdminDict","RestartPCBool"])) { $(".UACClient-pyOpenRPADict-AdminDict-RestartPCBool").show(); } + } - mGlobal.UserRoleUpdate() // Cal the update User Roles function // Orchestrator model mGlobal.WorkingDirectoryPathStr = null mGlobal.OrchestratorModelUpdate=function() { diff --git a/Sources/pyOpenRPA/Orchestrator/Web/Index.xhtml b/Sources/pyOpenRPA/Orchestrator/Web/Index.xhtml index 8b248b86..6adce89d 100644 --- a/Sources/pyOpenRPA/Orchestrator/Web/Index.xhtml +++ b/Sources/pyOpenRPA/Orchestrator/Web/Index.xhtml @@ -63,7 +63,7 @@
-
+
-