proxy-agents icon indicating copy to clipboard operation
proxy-agents copied to clipboard

Username and password auth for pac-proxy-agent.

Open Ghxst opened this issue 1 year ago • 3 comments

Hey, first of all thanks for this repo, it's been really useful! I was super happy to see some of the other agents supported username and password auth but haven't been able to get this to work with the pac-proxy-agent.

Simplest pac file I could write for testing:

function FindProxyForURL(url, host) {
    return 'PROXY username:password@host:port';
}

Without username:password@ it works like intended.

Ghxst avatar Jul 07 '23 02:07 Ghxst

Ya that seems reasonable. Can you also confirm if that syntax works when using this PAC file in the web browser?

Edit: Seems like the answer is no, PAC files in general do not support this syntax: https://serverfault.com/questions/394130/how-to-automatically-configure-username-password-with-proxy-pac-file

TooTallNate avatar Jul 10 '23 18:07 TooTallNate

I tested this on chrome 114 with the --proxy-pac-url command line flag. Auth seemed to work fine, I'll double check to make sure.

Edit: just read your link, interesting, I suppose chrome is adding some additional logic to make it work, is it worth investigating or should I close this issue in favor of setting up a proxy server in between like suggested in the comments?

Ghxst avatar Jul 10 '23 18:07 Ghxst

Well, one route we could go is to add an option to the PacProxyAgent constructor, where you could specify a pair of hostname:port and the username:password to use when connecting to those proxies. Something like:

new PacProxyAgent('https://example.com/proxy.pac', {
  authentication: {
    'my-proxy.com:3128': 'username:password'
  }
});

That said, if it works in Chrome then I'd be fine supporting it in this module. I'll try to confirm myself as well.

TooTallNate avatar Jul 10 '23 18:07 TooTallNate