splunk / splunk-add-on-microsoft-azure

Splunk Add-on for Microsoft Azure
Apache License 2.0
11 stars 7 forks source link

Authenticated Proxy Fails #68

Open tomworster opened 8 months ago

tomworster commented 8 months ago

Standard requests are not using the proxy username/password.

Was able to fix this as a workaround by modifying utils.py get_proxy as follows:

First, import quote from urllib.parse:

from urllib.parse import quote

Second, update get_proxy when proxy_type is "requests" to add the username/password and format the proxy url as http://username>:<password>@<url:.

        if proxy_type.lower()=="requests":
            user_pass = ""
            if proxy["proxy_username"] and proxy["proxy_password"]:
                username = quote(proxy["proxy_username"], safe="")
                password = quote(proxy["proxy_password"], safe="")
                user_pass = f"{username}:{password}@"

            proxy_url = "%s%s%s:%s" % ("http://", user_pass, proxy["proxy_url"], proxy["proxy_port"])
            proxies = {
                    "http" : proxy_url,
                    "https" : proxy_url
                }

Not clear why the UI has the username/password but it is not in use by the code.

RandomUser1215R commented 1 month ago

I had the same problem and your code fixed it !

Thanks a lot @tomworster

I hope it'll be fixed in the next version cc @JasonConger