How do I limit the client IPs that a workflow receives traffic from?

This topic was automatically generated from Slack. You can find the original thread here.

Michael Barnett : Hello, how can I restrict request to my PD webhook by ip address/ip address range?

Dylan Sather (Pipedream) : Hi , do you need to restrict the set of IP addresses that are allowed to send HTTP requests to Pipedream?

Or do you need to know which IPs Pipedream sends HTTP traffic from, so you can whitelist Pipedream IPs in some service?

Michael Barnett : Restrict IP’s that may send to Pipedream

Michael Barnett : Only for a specific inbound webhook

Dylan Sather (Pipedream) : There’s not a way to restrict the traffic from hitting your workflow, but you can check to see if the incoming IP is in a given range, and end early if it’s not, using a workflow like this.

Dylan Sather (Pipedream) : I published the first step as an action called Is this IP address in this Subnet?, so you can search for that in the step selector

Dylan Sather (Pipedream) : then the next step of the example workflow uses $end() to end the workflow early if the IP isn’t in the range: https://docs.pipedream.com/workflows/steps/code/#end

Dylan Sather (Pipedream) : otherwise, the rest of the workflow will run - you can add any steps below these and they’ll only run when the IP is in the correct range

Michael Barnett : I understand - Thanks for the help…what if I need to check multiple IP’s in a single call? For example, my app might send from up to 5 IP’s different subnets.

Michael Barnett : This package can accept an array of IP’s - https://www.npmjs.com/package/ip-range-check

Dylan Sather (Pipedream) : yes if you’d like, feel free to use that package. I also published an action called Is IP in list of IPs?

Dylan Sather (Pipedream) : https://pipedream.com/@dylan/check-if-incoming-ip-address-matches-any-of-5-ips-p_A2CQAjZ/edit

Dylan Sather (Pipedream) :

Dylan Sather (Pipedream) : publishing an action that covers the multiple subnets case, as well

Michael Barnett : Thats super fast

Michael Barnett : and I get the request ip with {{event.client_ip}}. ?

Dylan Sather (Pipedream) : that’s correct

Dylan Sather (Pipedream) : I ended up modifying the original action to accept a list of subnets. The new action is named Is this IP address in this list of Subnets? https://pipedream.com/@dylan/check-if-incoming-ip-address-is-in-the-provided-range-p_MOC3qP6/edit

Michael Barnett : Implemented, thanks!