Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
logger message fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TiagoMF20 committed Aug 5, 2021
1 parent c6c3f44 commit ee904b0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/blueprints/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ def resource_request(path):
if resource_id is not None:
try:
logger.debug("Matched resource: "+str(resource_id))
# Generate ticket if token is not present
# Generate ticket if token is not present
ticket = ""
try:
#Ticket for default protected_XXX scopes
ticket = uma_handler.request_access_ticket([{"resource_id": resource_id, "resource_scopes": scopes }])
response.headers["WWW-Authenticate"] = "UMA realm="+g_config["realm"]+",as_uri="+g_config["auth_server_url"]+",ticket="+ticket
response.status_code = 401 # Answer with "Unauthorized" as per the standard spec.
activity = {"Ticket":ticket,"Description":"Invalid token, generating ticket for resource:"+resource_id}
logger.info(log_handler.format_message(subcomponent="AUTHORIZE",action_id="HTTP",action_type=http_method,log_code=2104,activity=activity))
logger.info(log_handler.format_message(subcomponent="PROXY",action_id="HTTP",action_type=request.method,log_code=2104,activity=activity))
return response
except Exception as e:
pass #Resource is not registered with default scopes
Expand All @@ -111,7 +111,7 @@ def resource_request(path):
response.headers["WWW-Authenticate"] = "UMA realm="+g_config["realm"]+",as_uri="+g_config["auth_server_url"]+",ticket="+ticket
response.status_code = 401 # Answer with "Unauthorized" as per the standard spec.
activity = {"Ticket":ticket,"Description":"Invalid token, generating ticket for resource:"+resource_id}
logger.info(log_handler.format_message(subcomponent="AUTHORIZE",action_id="HTTP",action_type=http_method,log_code=2104,activity=activity))
logger.info(log_handler.format_message(subcomponent="PROXY",action_id="HTTP",action_type=request.method,log_code=2104,activity=activity))
return response
except Exception as e:
pass #Resource is not registered with "Authenticated" scope
Expand All @@ -121,11 +121,11 @@ def resource_request(path):
response.headers["WWW-Authenticate"] = "UMA realm="+g_config["realm"]+",as_uri="+g_config["auth_server_url"]+",ticket="+ticket
response.status_code = 401 # Answer with "Unauthorized" as per the standard spec.
activity = {"Ticket":ticket,"Description":"Invalid token, generating ticket for resource:"+resource_id}
logger.info(log_handler.format_message(subcomponent="AUTHORIZE",action_id="HTTP",action_type=http_method,log_code=2104,activity=activity))
logger.info(log_handler.format_message(subcomponent="PROXY",action_id="HTTP",action_type=request.method,log_code=2104,activity=activity))
return response
except Exception as e:
#Resource is not registered with any known scope, throw generalized exception
raise Exception("An error occurred while requesting permission for a resource: no valid scopes found for specified resource")
raise Exception("An error occurred while requesting permission for a resource: 500: no valid scopes found for specified resource")
except Exception as e:
response.status_code = int(str(e).split(":")[1].strip())
response.headers["Error"] = str(e)
Expand Down

0 comments on commit ee904b0

Please sign in to comment.