merge-requests/1/merge
Ivan Maslov 2 years ago
parent cce7f1ebe3
commit b3331d3782

@ -64,7 +64,7 @@ def IdentifyAuthorize(inRequest:Request, inResponse:Response,
mOpenRPA["Domain"] = lResult["Domain"] mOpenRPA["Domain"] = lResult["Domain"]
mOpenRPA["User"] = lResult["User"] mOpenRPA["User"] = lResult["User"]
mOpenRPA["IsSuperToken"] = __Orchestrator__.GSettingsGet().get("ServerDict", {}).get("AccessUsers", {}).get("AuthTokensDict", {}).get(mOpenRPA["AuthToken"], {}).get("FlagDoNotExpire", False) mOpenRPA["IsSuperToken"] = __Orchestrator__.GSettingsGet().get("ServerDict", {}).get("AccessUsers", {}).get("AuthTokensDict", {}).get(mOpenRPA["AuthToken"], {}).get("FlagDoNotExpire", False)
return mOpenRPA return lAuthToken
###################################### ######################################
#Way 2 - try to logon #Way 2 - try to logon
if len(lHeaderAuthorization) == 2: if len(lHeaderAuthorization) == 2:
@ -95,15 +95,15 @@ def IdentifyAuthorize(inRequest:Request, inResponse:Response,
mOpenRPA["Domain"] = lResult["Domain"] mOpenRPA["Domain"] = lResult["Domain"]
mOpenRPA["User"] = lResult["User"] mOpenRPA["User"] = lResult["User"]
mOpenRPA["IsSuperToken"] = __Orchestrator__.GSettingsGet().get("ServerDict", {}).get("AccessUsers", {}).get("AuthTokensDict", {}).get(mOpenRPA["AuthToken"], {}).get("FlagDoNotExpire", False) mOpenRPA["IsSuperToken"] = __Orchestrator__.GSettingsGet().get("ServerDict", {}).get("AccessUsers", {}).get("AuthTokensDict", {}).get(mOpenRPA["AuthToken"], {}).get("FlagDoNotExpire", False)
return mOpenRPA return lAuthToken
#inRequest.OpenRPASetCookie = {} #inRequest.OpenRPASetCookie = {}
#New engine of server #New engine of server
#inRequest.OpenRPAResponseDict["SetCookies"]["AuthToken"] = lAuthToken #inRequest.OpenRPAResponseDict["SetCookies"]["AuthToken"] = lAuthToken
else: else:
raise HTTPException(status_code=401, detail="here is the details", headers={}) raise HTTPException(status_code=401, detail="Попытка авторизации не прошла успешно (неверная пара логин / пароль)", headers={})
###################################### ######################################
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="Попытка авторизации не прошла успешно (неполная пара логин / пароль)", headers={'Content-type':'text/html', 'WWW-Authenticate':'Basic'})
lRouteList =[] lRouteList =[]
for lItem in app.router.routes: for lItem in app.router.routes:
@ -118,8 +118,8 @@ for lItem in lRouteList:
tags=["FastAPI"] tags=["FastAPI"]
) )
def BackwardCompatibility(inRequest:Request, inResponse:Response, inBodyStr:str = Body(""), inAuthDict = None): def BackwardCompatibility(inRequest:Request, inResponse:Response, inBodyStr:str = Body(""), inAuthTokenStr = None):
lHTTPRequest = ServerBC.HTTPRequestOld(inRequest=inRequest, inResponse=inResponse, inAuthDict=inAuthDict) lHTTPRequest = ServerBC.HTTPRequestOld(inRequest=inRequest, inResponse=inResponse, inAuthTokenStr=inAuthTokenStr)
lHTTPRequest.path = inRequest.url.path lHTTPRequest.path = inRequest.url.path
lHTTPRequest.body = inBodyStr lHTTPRequest.body = inBodyStr
lHTTPRequest.client_address = [inRequest.client.host] lHTTPRequest.client_address = [inRequest.client.host]
@ -132,13 +132,13 @@ def BackwardCompatibility(inRequest:Request, inResponse:Response, inBodyStr:str
#WRAPPERS! #WRAPPERS!
def BackwardCompatibityWrapperAuth(inRequest:Request, inResponse:Response, inBodyStr:str = Body(""), def BackwardCompatibityWrapperAuth(inRequest:Request, inResponse:Response, inBodyStr:str = Body(""),
inAuthDict:dict=Depends(IdentifyAuthorize)): # Old from v1.3.1 (updated to FastAPI) inAuthTokenStr:str=Depends(IdentifyAuthorize)): # Old from v1.3.1 (updated to FastAPI)
return BackwardCompatibility(inRequest = inRequest, inResponse = inResponse, inBodyStr = inBodyStr, inAuthDict=inAuthDict) return BackwardCompatibility(inRequest = inRequest, inResponse = inResponse, inBodyStr = inBodyStr, inAuthTokenStr=inAuthTokenStr)
def BackwardCompatibityWrapperNoAuth(inRequest:Request, inResponse:Response, inBodyStr:str = Body("")): # Old from v1.3.1 (updated to FastAPI) def BackwardCompatibityWrapperNoAuth(inRequest:Request, inResponse:Response, inBodyStr:str = Body("")): # Old from v1.3.1 (updated to FastAPI)
return BackwardCompatibility(inRequest = inRequest, inResponse = inResponse, inBodyStr = inBodyStr, inAuthDict=None) return BackwardCompatibility(inRequest = inRequest, inResponse = inResponse, inBodyStr = inBodyStr, inAuthDict=None)
def BackwardCompatibityBeginWrapperAuth(inBeginTokenStr, inRequest:Request, inResponse:Response, inBodyStr:str = Body(""), def BackwardCompatibityBeginWrapperAuth(inBeginTokenStr, inRequest:Request, inResponse:Response, inBodyStr:str = Body(""),
inAuthDict:dict=Depends(IdentifyAuthorize)): # Old from v1.3.1 (updated to FastAPI) inAuthTokenStr:str=Depends(IdentifyAuthorize)): # Old from v1.3.1 (updated to FastAPI)
return BackwardCompatibility(inRequest = inRequest, inResponse = inResponse, inBodyStr = inBodyStr, inAuthDict=inAuthDict) return BackwardCompatibility(inRequest = inRequest, inResponse = inResponse, inBodyStr = inBodyStr, inAuthTokenStr=inAuthTokenStr)
def BackwardCompatibityBeginWrapperNoAuth(inBeginTokenStr, inRequest:Request, inResponse:Response, inBodyStr:str = Body("")): # Old from v1.3.1 (updated to FastAPI) def BackwardCompatibityBeginWrapperNoAuth(inBeginTokenStr, inRequest:Request, inResponse:Response, inBodyStr:str = Body("")): # Old from v1.3.1 (updated to FastAPI)
return BackwardCompatibility(inRequest = inRequest, inResponse = inResponse, inBodyStr = inBodyStr, inAuthDict=None) return BackwardCompatibility(inRequest = inRequest, inResponse = inResponse, inBodyStr = inBodyStr, inAuthDict=None)

@ -154,16 +154,16 @@ class HTTPRequestOld():
OpenRPA: dict = {} OpenRPA: dict = {}
headers={} headers={}
def __init__(self,inRequest,inResponse,inAuthDict): def __init__(self,inRequest,inResponse,inAuthTokenStr):
self.mRequest = inRequest self.mRequest = inRequest
self.mResponse = inResponse self.mResponse = inResponse
if inAuthDict is None: if inAuthTokenStr != None:
self.OpenRPA = {} self.OpenRPA = {}
self.OpenRPA["IsSuperToken"] = False self.OpenRPA["IsSuperToken"] = __Orchestrator__.WebUserIsSuperToken(inAuthTokenStr=inAuthTokenStr)
self.OpenRPA["AuthToken"] = None self.OpenRPA["AuthToken"] = inAuthTokenStr
self.OpenRPA["Domain"] = None self.OpenRPA["Domain"] = __Orchestrator__.WebUserDomainGet(inAuthTokenStr=inAuthTokenStr)
self.OpenRPA["User"] = None self.OpenRPA["User"] = __Orchestrator__.WebUserLoginGet(inAuthTokenStr=inAuthTokenStr)
else: self.OpenRPA = inAuthDict else: self.OpenRPA = {"IsSuperToken":False, "AuthToken":None, "Domain":None, "User":None}
self.headers=inRequest.headers self.headers=inRequest.headers
# Def to check User Role access grants # Def to check User Role access grants

Loading…
Cancel
Save