Skip to content
Snippets Groups Projects
Unverified Commit 141e5da4 authored by SQAMPY's avatar SQAMPY Committed by GitHub
Browse files

Forward the source IP as value for "client" in sendRequest()

parent 0a2b099e
Branches
Tags
No related merge requests found
......@@ -422,6 +422,19 @@ class PrivacyIDEA
assert('string' === gettype($httpMethod));
assert('string' === gettype($endpoint));
/**
* Sending the "client" field allows us to use the original IP address in policies in Privacyidea.
*/
$serverHeaders = $_SERVER;
foreach(array("X-Forwarded-For", "HTTP_X_FORWARDED_FOR", "REMOTE_ADDR") as $clientkey) {
if (array_key_exists($clientkey, $serverHeaders)) {
$client_ip = $serverHeaders[$clientkey];
$this->debugLog("Forwarding Client IP: " . $clientkey . ": " . $client_ip);
$params['client'] = $client_ip;
break;
}
}
$this->debugLog("Sending " . http_build_query($params, '', ', ') . " to " . $endpoint);
$completeUrl = $this->serverURL . $endpoint;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment