1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

change how we detect the current user to avoid a nuanced recursion error

see: https://github.com/ansible/ansible-tower/issues/7802
This commit is contained in:
Ryan Petrello 2017-12-08 09:56:01 -05:00
parent 0dc4fa975b
commit ce94ba4c83
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777
2 changed files with 7 additions and 3 deletions

View File

@ -21,7 +21,7 @@ from django.utils.translation import ugettext_lazy as _
# Django REST Framework
from rest_framework.authentication import get_authorization_header
from rest_framework.exceptions import PermissionDenied
from rest_framework.exceptions import PermissionDenied, AuthenticationFailed
from rest_framework import generics
from rest_framework.response import Response
from rest_framework import status
@ -115,6 +115,10 @@ class APIView(views.APIView):
drf_request = super(APIView, self).initialize_request(request, *args, **kwargs)
request.drf_request = drf_request
try:
request.drf_request_user = getattr(drf_request, 'user', False)
except AuthenticationFailed:
request.drf_request_user = None
return drf_request
def finalize_response(self, request, response, *args, **kwargs):

View File

@ -558,8 +558,8 @@ def get_current_user_from_drf_request(sender, **kwargs):
drf_request on the underlying Django Request object.
'''
request = get_current_request()
drf_request = getattr(request, 'drf_request', None)
return (getattr(drf_request, 'user', False), 0)
drf_request_user = getattr(request, 'drf_request_user', False)
return (drf_request_user, 0)
@receiver(pre_delete, sender=Organization)