Closed carl-alberto closed 4 years ago
By checking the code further, it seems this function can be overridden by a filter:
function overrid_ip( $ip ) {
$ip = $_SERVER['REMOTE_ADDR'];
return $ip;
}
add_filter( 'give_get_ip', 'overrid_ip' );
Issue moved to impress-org/give-authorize-gateway #102 via ZenHub
Bug Report
User Story
As a GiveWP user with Authorize.net auto-renewal setup, I want the plugin to accurately record the IP addresses so that auto-renewals from Authorize.net will not fail.
Current Behavior
Symptomps will show in the
Donation Meta
on individual donations page:Tracing back to the code, one way the plugin records IP is from this code:
https://github.com/impress-org/give/blob/894a98b59843c4566a6a010e23f450c132e6912d/includes/misc-functions.php#L156-L158
Which uses the server variable
$_SERVER['HTTP_X_FORWARDED_FOR']
, for hosts that use 301 redirects in forcing the HTTPS to load (like in Pantheon) will always give at least 2 comma separate values of IPs that would be normal as per specifications https://en.wikipedia.org/wiki/X-Forwarded-For#Format:Expected Behavior
All IPs should be recorded in the DB as the correct format
Bug Type
Related & Steps to Reproduce
I believe @Benunc has the details and have a test setup ready in Pantheon because he is the one handling this issue with one of the clients.
Possible Solution
Put additional checks when values from
$_SERVER['HTTP_X_FORWARDED_FOR']
for these possible scenarios: 1) Single IP - proceed in saving 2) 2 IPs but the same IP, truncate the duplicate before saving 3) 2 or more different IP means the site is in a proxy, might return an error or get the originating IPHappy to help out with a PR if that would hasten the resolution.
Acceptance Criteria
Environment
Operating System
Browser
WordPress System Info
WP v5.1.1 Give - Authorize.net Gateway - v 1.4.6 Give - Donation Plugin - v2.4.7 Give - Recurring Donations - v1.8.12