django-rest-passwordreset
django-rest-passwordreset copied to clipboard
[BUG] X-Forwarded-For containing multiple IPs does not respect inet data type
Describe the bug
When using DJANGO_REST_PASSWORDRESET_IP_ADDRESS_HEADER
behind a proxy server, the actual value may contain multiple IPs, separated by a comma, with the first value being the client IP and the last being the last proxy server hit.
In such a scenario, inserting into the DB fails with an error because the data tried to be inserted is not of inet
data type. Looking at the code, there is not split attempting to just use the client IP (first value). Alternatively, the model should be changed to not be inet
How to reproduce Test behind a proxy server
Internal Server Error: /auth/password-reset/
REDACTED | Traceback (most recent call last):
REDACTED | File "/usr/local/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
REDACTED | return self.cursor.execute(sql, params)
REDACTED | psycopg2.errors.InvalidTextRepresentation: invalid input syntax for type inet: "82.xx.xx.xx, 192.168.32.1"
By the way, this is also wrong in the docs:
The variable should be DJANGO_REST_PASSWORDRESET_HTTP_USER_AGENT_HEADER