mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 17:28:51 -03:30
Rename delete
* Include a bit of context into the name of the delete function. The HTTP_ added prepended string may be unexpected if Django's header transformation isn't top of mind.
This commit is contained in:
committed by
Chris Meyers
parent
8645fe5c57
commit
bef9ef10bb
@@ -44,7 +44,7 @@ from awx.main.models.rbac import give_creator_permissions
|
|||||||
from awx.main.access import optimize_queryset
|
from awx.main.access import optimize_queryset
|
||||||
from awx.main.utils import camelcase_to_underscore, get_search_fields, getattrd, get_object_or_400, decrypt_field, get_awx_version
|
from awx.main.utils import camelcase_to_underscore, get_search_fields, getattrd, get_object_or_400, decrypt_field, get_awx_version
|
||||||
from awx.main.utils.licensing import server_product_name
|
from awx.main.utils.licensing import server_product_name
|
||||||
from awx.main.utils.proxy import is_proxy_in_headers, delete_headers
|
from awx.main.utils.proxy import is_proxy_in_headers, delete_headers_starting_with_http
|
||||||
from awx.main.views import ApiErrorView
|
from awx.main.views import ApiErrorView
|
||||||
from awx.api.serializers import ResourceAccessListElementSerializer, CopySerializer
|
from awx.api.serializers import ResourceAccessListElementSerializer, CopySerializer
|
||||||
from awx.api.versioning import URLPathVersioning
|
from awx.api.versioning import URLPathVersioning
|
||||||
@@ -171,7 +171,7 @@ class APIView(views.APIView):
|
|||||||
# they respect the allowed proxy list
|
# they respect the allowed proxy list
|
||||||
if settings.PROXY_IP_ALLOWED_LIST:
|
if settings.PROXY_IP_ALLOWED_LIST:
|
||||||
if not is_proxy_in_headers(self.request, settings.PROXY_IP_ALLOWED_LIST, remote_headers):
|
if not is_proxy_in_headers(self.request, settings.PROXY_IP_ALLOWED_LIST, remote_headers):
|
||||||
delete_headers(request, settings.REMOTE_HOST_HEADERS)
|
delete_headers_starting_with_http(request, settings.REMOTE_HOST_HEADERS)
|
||||||
|
|
||||||
drf_request = super(APIView, self).initialize_request(request, *args, **kwargs)
|
drf_request = super(APIView, self).initialize_request(request, *args, **kwargs)
|
||||||
request.drf_request = drf_request
|
request.drf_request = drf_request
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ def is_proxy_in_headers(request: Request, proxy_list: list[str], headers: list[s
|
|||||||
return bool(remote_hosts.intersection(set(proxy_list)))
|
return bool(remote_hosts.intersection(set(proxy_list)))
|
||||||
|
|
||||||
|
|
||||||
def delete_headers(request: Request, headers: list[str]):
|
def delete_headers_starting_with_http(request: Request, headers: list[str]):
|
||||||
for header in headers:
|
for header in headers:
|
||||||
if header.startswith('HTTP_'):
|
if header.startswith('HTTP_'):
|
||||||
request.environ.pop(header, None)
|
request.environ.pop(header, None)
|
||||||
|
|||||||
Reference in New Issue
Block a user