orc server fixes (before renamings)

merge-requests/1/merge
robo-bo 2 years ago
parent 1baacac24e
commit cfbdefd161

@ -498,16 +498,18 @@ class HTTPRequestOld():
from pyOpenRPA import __version__
# инициализация # ИНИЦИАЛИЗАЦИЯ FASTAPI!
app = FastAPI() app = FastAPI(
title = "pyOpenRPA (ORPA) Orchestrator",
# hello world, метод GET, возврат строки description = "Сервер оркестратора pyOpenRPA Orchestrator",
#@app.get("/", response_class=PlainTextResponse) version = __version__,
#async def hello(): openapi_url="/orpa/fastapi/openapi.json",
# return "Hello World!" docs_url = "/orpa/fastapi/docs",
redoc_url = "/orpa/fastapi/redoc",
swagger_ui_oauth2_redirect_url = "/orpa/fastapi/docs/oauth2-redirect",
)
def IdentifyAuthorize(inRequest:Request, inResponse:Response, def IdentifyAuthorize(inRequest:Request, inResponse:Response,
inCookiesStr: Union[str, None] = Header(default=None,alias="Cookie"), inCookiesStr: Union[str, None] = Header(default=None,alias="Cookie"),
@ -574,6 +576,18 @@ def IdentifyAuthorize(inRequest:Request, inResponse:Response,
else: else:
raise HTTPException(status_code=401, detail="here is the details", headers={'Content-type':'text/html', 'WWW-Authenticate':'Basic'}) raise HTTPException(status_code=401, detail="here is the details", headers={'Content-type':'text/html', 'WWW-Authenticate':'Basic'})
lRouteList =[]
for lItem in app.router.routes:
lRouteList.append(lItem)
app.router.routes=[]
for lItem in lRouteList:
app.add_api_route(
path=lItem.path,
endpoint=lItem.endpoint,
methods=["GET"],
dependencies=[Depends(IdentifyAuthorize)],
tags=["FastAPI"]
)
def BackwardCompatibility(inRequest:Request, inResponse:Response, inBodyStr:str = Body(""), inAuthDict = None): def BackwardCompatibility(inRequest:Request, inResponse:Response, inBodyStr:str = Body(""), inAuthDict = None):
lHTTPRequest = HTTPRequestOld(inRequest=inRequest, inResponse=inResponse, inAuthDict=inAuthDict) lHTTPRequest = HTTPRequestOld(inRequest=inRequest, inResponse=inResponse, inAuthDict=inAuthDict)
@ -616,6 +630,7 @@ def InitFastAPI():
ServerSettings.SettingsUpdate(gSettingsDict) ServerSettings.SettingsUpdate(gSettingsDict)
lL = gSettingsDict.get("Logger",None) lL = gSettingsDict.get("Logger",None)
gSettingsDict["ServerDict"]["ServerThread"] = app gSettingsDict["ServerDict"]["ServerThread"] = app
for lConnectItemDict in gSettingsDict["ServerDict"]["URLList"]: for lConnectItemDict in gSettingsDict["ServerDict"]["URLList"]:
if "ResponseFolderPath" in lConnectItemDict: if "ResponseFolderPath" in lConnectItemDict:
app.mount(lConnectItemDict["URL"], app.mount(lConnectItemDict["URL"],
@ -628,14 +643,16 @@ def InitFastAPI():
path=lConnectItemDict["URL"], path=lConnectItemDict["URL"],
endpoint=BackwardCompatibityWrapperAuth, endpoint=BackwardCompatibityWrapperAuth,
response_class=PlainTextResponse, response_class=PlainTextResponse,
methods=[lConnectItemDict["Method"]] methods=[lConnectItemDict["Method"]],
tags=["BackwardCompatibility"]
) )
else: else:
app.add_api_route( app.add_api_route(
path=lConnectItemDict["URL"], path=lConnectItemDict["URL"],
endpoint=BackwardCompatibityWrapperNoAuth, endpoint=BackwardCompatibityWrapperNoAuth,
response_class=PlainTextResponse, response_class=PlainTextResponse,
methods=[lConnectItemDict["Method"]] methods=[lConnectItemDict["Method"]],
tags=["BackwardCompatibility"]
) )
elif lConnectItemDict.get("MatchType") in ["BeginWith", "Contains"]: elif lConnectItemDict.get("MatchType") in ["BeginWith", "Contains"]:
lURLStr = lConnectItemDict["URL"] lURLStr = lConnectItemDict["URL"]
@ -646,14 +663,16 @@ def InitFastAPI():
path=lURLStr, path=lURLStr,
endpoint=BackwardCompatibityBeginWrapperAuth, endpoint=BackwardCompatibityBeginWrapperAuth,
response_class=PlainTextResponse, response_class=PlainTextResponse,
methods=[lConnectItemDict["Method"]] methods=[lConnectItemDict["Method"]],
tags=["BackwardCompatibility"]
) )
else: else:
app.add_api_route( app.add_api_route(
path=lURLStr, path=lURLStr,
endpoint=BackwardCompatibityBeginWrapperNoAuth, endpoint=BackwardCompatibityBeginWrapperNoAuth,
response_class=PlainTextResponse, response_class=PlainTextResponse,
methods=[lConnectItemDict["Method"]] methods=[lConnectItemDict["Method"]],
tags=["BackwardCompatibility"]
) )
uvicorn.run('pyOpenRPA.Orchestrator.Server:app', host='0.0.0.0', port=1024) uvicorn.run('pyOpenRPA.Orchestrator.Server:app', host='0.0.0.0', port=1024)

Loading…
Cancel
Save