froger-me / wp-remote-users-sync

Synchronise users across WordPress websites
GNU General Public License v3.0
72 stars 33 forks source link

Functionality to whitelist IP ranges #50

Closed honggyu420 closed 2 years ago

honggyu420 commented 2 years ago

What?

The current version only supports lists of IP addresses for Wordpress sites to whitelist. This PR expands the functionality to cover IP ranges.

Why?

For when IP address of Wordpress sites are dynamic within subnets. I ran into this problem as my Wordpress sites were behind Cloudflare proxies and wanted to whitelist Cloudflare IP ranges.

How?

Each item in $ip_whitelist will be converted to a valid CIDR, appending /32 to ip addresses. A new method called cidr_match was implemented to check the remote server IP address to the whitelisted CIDRs.

honggyu420 commented 2 years ago

Thanks for the feedback! Just made another commit following your suggestions.

tamara-m commented 2 years ago

Hi guys,

@honggyu420 Understanding this PR allows to enter these in the Whitelist IPs setting, correct?

https://www.cloudflare.com/ips/

honggyu420 commented 2 years ago

@tamara-m yup!

tamara-m commented 2 years ago

Cool! Thank you 🙂