|
|
|
@ -146,7 +146,8 @@ def UserAccessCheckBefore(inMethod, inRequest):
|
|
|
|
|
########################################
|
|
|
|
|
#Check general before rule (without User domain)
|
|
|
|
|
#Check rules
|
|
|
|
|
for lAccessRuleItem in gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("RuleMethodMatchURLBeforeList", []):
|
|
|
|
|
inRuleMatchURLList = gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("RuleMethodMatchURLBeforeList", [])
|
|
|
|
|
for lAccessRuleItem in inRuleMatchURLList:
|
|
|
|
|
#Go next execution if flag is false
|
|
|
|
|
if not lResult:
|
|
|
|
|
#Check if Method is identical
|
|
|
|
@ -178,31 +179,35 @@ def UserAccessCheckBefore(inMethod, inRequest):
|
|
|
|
|
#Check access by User Domain
|
|
|
|
|
#Check rules to find first appicable
|
|
|
|
|
#Check rules
|
|
|
|
|
for lAccessRuleItem in gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("RuleDomainUserDict", {}).get((lUserDict["Domain"].upper(), lUserDict["User"].upper()), {}).get("MethodMatchURLBeforeList", []):
|
|
|
|
|
#Go next execution if flag is false
|
|
|
|
|
if not lResult:
|
|
|
|
|
#Check if Method is identical
|
|
|
|
|
if lAccessRuleItem["Method"].upper() == inMethod:
|
|
|
|
|
#check Match type variant: BeginWith
|
|
|
|
|
if lAccessRuleItem["MatchType"].upper() == "BEGINWITH":
|
|
|
|
|
lURLPath = inRequest.path
|
|
|
|
|
lURLPath = lURLPath.upper()
|
|
|
|
|
if lURLPath.startswith(lAccessRuleItem["URL"].upper()):
|
|
|
|
|
lResult = HelpGetFlag(lAccessRuleItem, inRequest, gSettingsDict, lUserDict)
|
|
|
|
|
#check Match type variant: Contains
|
|
|
|
|
elif lAccessRuleItem["MatchType"].upper() == "CONTAINS":
|
|
|
|
|
lURLPath = inRequest.path
|
|
|
|
|
lURLPath = lURLPath.upper()
|
|
|
|
|
if lURLPath.contains(lAccessRuleItem["URL"].upper()):
|
|
|
|
|
lResult = HelpGetFlag(lAccessRuleItem, inRequest, gSettingsDict, lUserDict)
|
|
|
|
|
# check Match type variant: Equal
|
|
|
|
|
elif lAccessRuleItem["MatchType"].upper() == "EQUAL":
|
|
|
|
|
if lAccessRuleItem["URL"].upper() == inRequest.path.upper():
|
|
|
|
|
lResult = HelpGetFlag(lAccessRuleItem, inRequest, gSettingsDict, lUserDict)
|
|
|
|
|
# check Match type variant: EqualCase
|
|
|
|
|
elif lAccessRuleItem["MatchType"].upper() == "EQUALCASE":
|
|
|
|
|
if lAccessRuleItem["URL"] == inRequest.path:
|
|
|
|
|
lResult = HelpGetFlag(lAccessRuleItem, inRequest, gSettingsDict, lUserDict)
|
|
|
|
|
lMethodMatchURLList = gSettingsDict.get("ServerDict", {}).get("AccessUsers", {}).get("RuleDomainUserDict", {}).get((lUserDict["Domain"].upper(), lUserDict["User"].upper()), {}).get("MethodMatchURLBeforeList", [])
|
|
|
|
|
if len(lMethodMatchURLList) > 0:
|
|
|
|
|
for lAccessRuleItem in lMethodMatchURLList:
|
|
|
|
|
#Go next execution if flag is false
|
|
|
|
|
if not lResult:
|
|
|
|
|
#Check if Method is identical
|
|
|
|
|
if lAccessRuleItem["Method"].upper() == inMethod:
|
|
|
|
|
#check Match type variant: BeginWith
|
|
|
|
|
if lAccessRuleItem["MatchType"].upper() == "BEGINWITH":
|
|
|
|
|
lURLPath = inRequest.path
|
|
|
|
|
lURLPath = lURLPath.upper()
|
|
|
|
|
if lURLPath.startswith(lAccessRuleItem["URL"].upper()):
|
|
|
|
|
lResult = HelpGetFlag(lAccessRuleItem, inRequest, gSettingsDict, lUserDict)
|
|
|
|
|
#check Match type variant: Contains
|
|
|
|
|
elif lAccessRuleItem["MatchType"].upper() == "CONTAINS":
|
|
|
|
|
lURLPath = inRequest.path
|
|
|
|
|
lURLPath = lURLPath.upper()
|
|
|
|
|
if lURLPath.contains(lAccessRuleItem["URL"].upper()):
|
|
|
|
|
lResult = HelpGetFlag(lAccessRuleItem, inRequest, gSettingsDict, lUserDict)
|
|
|
|
|
# check Match type variant: Equal
|
|
|
|
|
elif lAccessRuleItem["MatchType"].upper() == "EQUAL":
|
|
|
|
|
if lAccessRuleItem["URL"].upper() == inRequest.path.upper():
|
|
|
|
|
lResult = HelpGetFlag(lAccessRuleItem, inRequest, gSettingsDict, lUserDict)
|
|
|
|
|
# check Match type variant: EqualCase
|
|
|
|
|
elif lAccessRuleItem["MatchType"].upper() == "EQUALCASE":
|
|
|
|
|
if lAccessRuleItem["URL"] == inRequest.path:
|
|
|
|
|
lResult = HelpGetFlag(lAccessRuleItem, inRequest, gSettingsDict, lUserDict)
|
|
|
|
|
else:
|
|
|
|
|
return True
|
|
|
|
|
#####################################
|
|
|
|
|
#####################################
|
|
|
|
|
#Return lResult
|
|
|
|
|