Fix long standing bug in determining remote IP
authorMagnus Hagander <magnus@hagander.net>
Thu, 17 Dec 2015 16:36:00 +0000 (17:36 +0100)
committerMagnus Hagander <magnus@hagander.net>
Thu, 17 Dec 2015 16:36:00 +0000 (17:36 +0100)
commit7de55adb97d3f2fc0c9f639029af33e080135600
treeacbcecf9025e9ac0168fde7b70f699540b636cd0
parent9c8006364eaad35a689608218cec71ca55bf6554
Fix long standing bug in determining remote IP

The check was for is_behind_cache without the (), meaning it always
returned true, which in turn meant we trusted all x-forwarded-for
headers. It was pretty hard to get them into the system, and
we didn't actually use it for anything other than locking survey
submissions, so it's not a big problem.

However, the basic logic was also wrong, as it assumes that all
SSL connections terminate directly at the backend server, which is
not necessarily true anymore.

The new version of the function will trust an X-Forwarded-For as
long as it's set on one of our frontend servers, regardless of if
it's an encrypted connection or not.
pgweb/util/misc.py