qwj / python-proxy

HTTP/HTTP2/HTTP3/Socks4/Socks5/Shadowsocks/ShadowsocksR/SSH/Redirect/Pf TCP/UDP asynchronous tunnel proxy implemented in Python 3 asyncio.
MIT License
1.93k stars 323 forks source link

Avoid unauthorised traffic? Authentication or whilelisting #148

Open ValerioNeriGit opened 2 years ago

ValerioNeriGit commented 2 years ago

Hi,

Great program! I noticed there is a way to blacklisting with rules, but I need more a whitelist or alternatively a way to allow only requests from a specific source (a password maybe?)

I notice that can be done something like : http://0.0.0.0:8080#username:password to have http auth but it does return Unauthorized HTTP using:

from requests.auth import HTTPBasicAuth
proxy_url = "http://localhost:8080"
proxies = {"http": proxy_url, "https": proxy_url}
requests.get("https://api.myip.com", proxies=proxies, auth=HTTPBasicAuth('username', 'password')).json()

Thank you