Skip to content

Commit

Permalink
Merge pull request #55 from Yoroitchi/main
Browse files Browse the repository at this point in the history
Adding space to status code when 403
  • Loading branch information
peppelinux authored Sep 12, 2024
2 parents 59f8f5a + d664a03 commit f626481
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions satosa_oidcop/idpy_oidcop.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _parse_request(
logger.error(err)
response = JsonResponse(
{"error": "unauthorized_client", "error_description": str(err)},
status="403",
status="403 Forbidden",
)
return self.send_response(response)
return parse_req
Expand Down Expand Up @@ -265,7 +265,7 @@ def _process_request(self, endpoint, context: Context, parse_req, http_headers):
"error": "invalid_request",
"error_description": "request cannot be processed",
},
status="403",
status="403 Forbidden",
)
return self.send_response(response)

Expand All @@ -276,7 +276,7 @@ def _log_request(self, context: ExtendedContext, msg: str, level: str = "info"):
getattr(logger, level)(logline)

def handle_error(
self, msg: str = None, excp: Exception = None, status: str = "403"
self, msg: str = None, excp: Exception = None, status: str = "403 Forbidden"
): # pragma: no cover
_msg = f'Something went wrong ... {excp or ""}'
msg = msg or _msg
Expand Down Expand Up @@ -380,7 +380,7 @@ def token_endpoint(self, context: ExtendedContext):
"error": "invalid_request",
"error_description": "Not owner of token",
},
status="403",
status="403 Forbidden",
)
return self.send_response(_response)

Expand All @@ -397,7 +397,7 @@ def token_endpoint(self, context: ExtendedContext):
if isinstance(proc_req, JsonResponse): # pragma: no cover
return self.send_response(proc_req)
elif isinstance(proc_req, TokenErrorResponse):
return self.send_response(JsonResponse(proc_req.to_dict(), status="403"))
return self.send_response(JsonResponse(proc_req.to_dict(), status="403 Forbidden"))

# TODO: remove when migrate to idpy-oidc
# PATCH https://github.com/UniversitaDellaCalabria/SATOSA-oidcop/issues/29
Expand Down Expand Up @@ -433,7 +433,7 @@ def userinfo_endpoint(self, context: ExtendedContext):
return self.send_response(
JsonResponse(
{"error": "invalid_client", "error_description": "<client not found>"},
status="403",
status="403 Forbidden",
)
)
else:
Expand All @@ -443,7 +443,7 @@ def userinfo_endpoint(self, context: ExtendedContext):
return self.send_response(
JsonResponse(
{"error": "invalid_token", "error_description": "<no loadable session>"},
status="403",
status="403 Forbidden",
)
)

Expand All @@ -455,7 +455,7 @@ def userinfo_endpoint(self, context: ExtendedContext):
return self.send_response(
JsonResponse(
{"error": "invalid_token", "error_description": "<TOKEN>"},
status="403",
status="403 Forbidden",
)
)

Expand All @@ -475,7 +475,7 @@ def userinfo_endpoint(self, context: ExtendedContext):
proc_req["response_args"]
if "response_args" in proc_req
else proc_req.to_dict(),
status="403",
status="403 Forbidden",
)
)

Expand Down Expand Up @@ -768,13 +768,13 @@ def _handle_backend_response(self, context: ExtendedContext, internal_resp):
return self.handle_error(excp=excp)

if isinstance(_args, ResponseMessage) and "error" in _args: # pragma: no cover
return self.send_response(JsonResponse(_args, status="403"))
return self.send_response(JsonResponse(_args, status="403 Forbidden"))
elif isinstance(
_args.get("response_args"), AuthorizationErrorResponse
): # pragma: no cover
rargs = _args.get("response_args")
logger.error(rargs)
response = JsonResponse(rargs.to_json(), status="403")
response = JsonResponse(rargs.to_json(), status="403 Forbidden")
return self.send_response(response)

info = endpoint.do_response(request=parse_req, **proc_req)
Expand Down

0 comments on commit f626481

Please sign in to comment.