Issue
I wrote a custom authentication and added a csrf check middleware in the authentication process. I am calling the below function in the authentication function.
def enforce_csrf(self, request):
"""
Enforce CSRF validation
"""
check = CSRFCheck()
check.process_request(request)
reason = check.process_view(request, None, (), {})
if reason:
# CSRF failed, bail with explicit error message
raise PermissionDenied('CSRF Failed: %s' % reason)
The CSRFCheck() function is a custom middleware and it looks like this.
class CSRFCheck(CsrfViewMiddleware):
def _reject(self, request, reason):
return reason
Now when I am trying to process the request, which requires authentication, I am getting the error:
TypeError: init() missing 1 required positional argument: 'get_response'
the same code is working perfectly in Django 3.2
Now, as far as I was able to debug, the CSRFCheck function is expecting a get_response method which I don't know where it is coming from.
Solution
Downgrade the Django version to 3.2.X till the bug is fixed.
Answered By - Mahesh Gupta
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.