sendgrid / python-http-client

Twilio SendGrid's Python HTTP Client for calling APIs
https://sendgrid.com
MIT License
125 stars 101 forks source link

proxy support required for use in private subnets without internet egress (PCI, IRAP, ISM, SOC2, ISO27018) #146

Open chrisdlangton opened 4 years ago

chrisdlangton commented 4 years ago

I cannot use send grid to send email from a webserver that is in a private subnet.

The webserver is behind a load balancer for ingress and requires a proxy (allowed hosts list) for egress.

This workload must be compliant, so best practices in security are required. This network topology is baseline standard (but more commonly users will leave everything ooen and exposed) for the basics to meet compliance for CIS, PCI, IRAP, ISM, SOC2, ISO27018

This lib can be removed as redundant from my observation. I suggest sendgrid use urllib to do HTTP instead of reinvent the wheel. if you need more features use requests instead of reinvent the aircraft. Both of these options allow a per-request proxy setting AND most importantly they both respect the operating system proxy setting (on linux it is the env var http_proxy and https_proxy case insensitive).

I would appreciate some attention on this. thank you

childish-sambino commented 4 years ago

This repo uses urllib but it does not expose its interfaces for adding request handlers: https://github.com/sendgrid/python-http-client/blob/5404e1523384d0aab51e841ae56759aab03d3a9e/python_http_client/client.py#L259-L264

I think adding a proxies arg to def http_request which would just be passed to a new ProxyHandler that's passed to the opener would work. Then the interface would look similar to that of requests. This would not handle the env vars use case, but that may not be difficult.

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.