diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-07-16 14:11:14 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-07-16 14:11:14 -0400 |
commit | 4364559805245260f89d70d590d0686250aa5f93 (patch) | |
tree | e9f7c3502d5b45ea481cdc716727afbbeeea1f43 | |
parent | 6cfce7720a88f383f85f9f7ea88a5dcdae87daa7 (diff) |
Handle HTTP header X-Real-IP to get IP address
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | app/Core/Http/Request.php | 1 | ||||
-rw-r--r-- | tests/units/Core/Http/RequestTest.php | 3 |
3 files changed, 5 insertions, 0 deletions
@@ -9,6 +9,7 @@ New features: Improvements: +* Handle header X-Real-IP to get IP address * Display project name for task auto-complete fields * Make search attributes not case sensitive * Display TOTP issuer for 2FA diff --git a/app/Core/Http/Request.php b/app/Core/Http/Request.php index e0df2d3c..2e84958d 100644 --- a/app/Core/Http/Request.php +++ b/app/Core/Http/Request.php @@ -301,6 +301,7 @@ class Request extends Base public function getIpAddress() { $keys = array( + 'HTTP_X_REAL_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', diff --git a/tests/units/Core/Http/RequestTest.php b/tests/units/Core/Http/RequestTest.php index 6fa796f7..1db0100c 100644 --- a/tests/units/Core/Http/RequestTest.php +++ b/tests/units/Core/Http/RequestTest.php @@ -169,6 +169,9 @@ class RequestTest extends Base $request = new Request($this->container, array(), array(), array(), array(), array()); $this->assertEquals('Unknown', $request->getIpAddress()); + $request = new Request($this->container, array('HTTP_X_REAL_IP' => '192.168.1.1,127.0.0.1'), array(), array(), array(), array()); + $this->assertEquals('192.168.1.1', $request->getIpAddress()); + $request = new Request($this->container, array('HTTP_X_FORWARDED_FOR' => '192.168.0.1,127.0.0.1'), array(), array(), array(), array()); $this->assertEquals('192.168.0.1', $request->getIpAddress()); |