anexia-it / django-rest-passwordreset

An extension of django rest framework, providing a configurable password reset strategy
BSD 3-Clause "New" or "Revised" License
419 stars 148 forks source link

REMOTE_ADDR not set (nginx, gunicorn and unix socket) #61

Closed goiaba closed 4 years ago

goiaba commented 5 years ago

The REMOTE_ADDR value is used to set the ip_address of a new instance of ResetPasswordToken class. Unfortunately, as state in this gunicorn issue, "... an unix socket has no remote address any more to comply with the CGI/WSGI spec.".

As a consequence, the persistence of the ResetPasswordToken throws an NotNullViolation exception, because ip_address is empty.

I see that you have introduced the DJANGO_REST_PASSWORDRESET_REMOTE_ADDR variable in the code, but as far as I could understand, this does not solve the problem because its hard coded value (set in the settings.py) will be used as the default value when REMOTE_ADDR does not exists in request.META.

So I'm wondering if it would be a good idea to allow developer to specify the variable (s)he wants to grab from request.META in order to fill ip_address variable.

anx-ckreuzberger commented 5 years ago

This feature is already "kind-of" there, there is a PR for it: #58

goiaba commented 5 years ago

Nice, Christian. Any idea of how long to the changes be available in a stable release?

anx-ckreuzberger commented 5 years ago

This feature has been released on PyPi in version 1.1.0rc3.

You should be able install and test it using

pip install django-rest-passwordreset==1.1.0rc3
ghost commented 4 years ago

I close this as 1.1.0 has been released.