Skip to content

Commit

Permalink
AB#98739 Strip x-api-key query parm from request
Browse files Browse the repository at this point in the history
Because when it is passed on to the DSO API, this does not recognize
this a DSO search param, so it errors.
  • Loading branch information
jjmurre committed Dec 21, 2023
1 parent 2bec853 commit dd25b23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion apikeyclient/src/apikeyclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ def __call__(self, request: HttpRequest):
if request.headers.get("User-Agent", "").startswith("Mozilla"):
return self._get_response(request)

token = request.headers.get("X-Api-Key", request.GET.get("x-api-key"))
token = request.headers.get("X-Api-Key")
if token is None:
token = request.GET.get("x-api-key")
if token:
# Make a copy of request.GET, to mutate it
request.GET = request.GET.copy()
# we need to get rid of the query param, DSO API does not recognize it
del request.GET['x-api-key']
if token is None and self._mandatory:
return JsonResponse({"message": "API key missing"}, status=HTTPStatus.UNAUTHORIZED)
if token is not None:
Expand Down
2 changes: 1 addition & 1 deletion client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def index(_request):
return HttpResponse('{"status": "ok"}', content_type="application/json")


urlpatterns = (re_path(r"^$", index),)
urlpatterns = (re_path(r"^$", index), re_path(r"^v1/wfs$", index))

application = get_wsgi_application()

Expand Down

0 comments on commit dd25b23

Please sign in to comment.