add support to get ip address from HTTP_X_FORWARDED_FOR header

This commit is contained in:
Chris Meyers
2015-02-02 17:24:57 -05:00
parent d9a2acb252
commit 76746e6c13
3 changed files with 99 additions and 8 deletions

View File

@@ -186,9 +186,10 @@ class AuthToken(BaseModel):
h = hashlib.sha1()
h.update(settings.SECRET_KEY)
for header in settings.REMOTE_HOST_HEADERS:
value = request.META.get(header, '').strip()
value = request.META.get(header, '').split(',')[0].strip()
if value:
h.update(value)
break
h.update(request.META.get('HTTP_USER_AGENT', ''))
return h.hexdigest()