in python/website/research_pacs/website/permission.py [0:0]
def _does_orthanc_request_match_patterns(request_patterns, method, path):
"""
Check if the request method and path matches one of the request patterns provided in the form
of "VERB path" (e.g. "GET /app/**). The request method can be any HTTP verb or "ANY". The
request path can contain a "*" (string that contains any characters expect "/") or "**"
(string that contains any characters)
Args:
request_patterns (list): List of request patterns in the form "VERB path"
method: Current request mathod
path: Current request path
"""
for pattern in request_patterns:
pattern_method, pattern_path = pattern.split(' ')
# Skip this request pattern if the method does not match
if not (method.lower() == pattern_method.lower() or pattern_method.lower() == 'any'):
continue
# Skip this request pattern if the path does not match
re_pattern = re.escape(pattern_path)
re_pattern = re_pattern.replace('\*\*', '.*')
re_pattern = re_pattern.replace('\*', '[^\/]*')
if not re.fullmatch(re_pattern.lower(), path.lower()):
continue
# Return True (match) if both the method and the path match
return True
# If none of the request patterns match, return False
return False