Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support proxy authentication by customized headers #51

Open
wikingwei opened this issue Dec 29, 2021 · 2 comments
Open

support proxy authentication by customized headers #51

wikingwei opened this issue Dec 29, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@wikingwei
Copy link

Hello,

Could the global-agent support customized headers? Especially like request header "proxy-authorization", which is required to secure proxy server access, and also is a http standard (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Proxy-Authorization).
As I can see global-agent's some logs show:
{"context":{"package":"global-agent","namespace":"Agent","logLevel":10,"target":{"host":"localhost","port":80,"proxy":{"authorization":null,"hostname":"proxy-example.com","port":8003},"tls":{}}},"message":"connecting","sequence":14,"time":1640756787290,"version":"1.0.0"}
In which, proxy info contains a header data "authorization", which maybe used by some proxy, but its value cannot be set, no interface to do it. And as I mentions above, the standard header "proxy-authorization" should be support and also provide interface to set its value.

Thanks!

@wikingwei
Copy link
Author

more update:
I see code below about convert authorization to proxy-authorization, but it uses fixed auth type "Basic". More types like "Bearer" and others are needed in actual cases.Could u please change it to be flexible to meet the need of all cases? Or fully customizable headers?

(https://github.com/gajus/global-agent/blob/master/src/classes/Agent.ts#L113)

  if (proxy.authorization) {
      request.setHeader('proxy-authorization', 'Basic ' + Buffer.from(proxy.authorization).toString('base64'));
    }

@gajus gajus added the enhancement New feature or request label Jan 3, 2022
@gajus
Copy link
Owner

gajus commented Jan 3, 2022

Open to a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants