mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -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:
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.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.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.api.serializers import ResourceAccessListElementSerializer, CopySerializer
|
||||
from awx.api.versioning import URLPathVersioning
|
||||
@ -171,7 +171,7 @@ class APIView(views.APIView):
|
||||
# they respect the allowed proxy list
|
||||
if settings.PROXY_IP_ALLOWED_LIST:
|
||||
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)
|
||||
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)))
|
||||
|
||||
|
||||
def delete_headers(request: Request, headers: list[str]):
|
||||
def delete_headers_starting_with_http(request: Request, headers: list[str]):
|
||||
for header in headers:
|
||||
if header.startswith('HTTP_'):
|
||||
request.environ.pop(header, None)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user