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

Update request.js #1194

Merged
merged 2 commits into from
Jun 13, 2022
Merged

Update request.js #1194

merged 2 commits into from
Jun 13, 2022

Conversation

dtadevos
Copy link
Contributor

Hi,

For private_key_jwt authentication, our Provider, running behind the proxy, tries to retrieve the JWKS keys by the specified jwksUri configured endpoint.

We pass the proxy agent through httpOptions, as described in the configuration, e.g.:

httpOptions(urlstr) {
  const options = url.parse('http://proxy-fr-croissy.gemalto.com:8080');
  const agent = new HttpsProxyAgent(options);
  return {
    agent,
    timeout: 5000,
  };
},

That unfortunatelly didn't work, and the debug undentified 3 issues:

  1. const helperOptions = omitBy({ timeout, agent, lookup }, Boolean);
    this code omits whatever is provided in httpOptions, so we had to change it to pickBy instead

  2. if (!(agent instanceof HttpsAgent) && !(agent instanceof HttpAgent))
    this condition is not satisfied when I pass an instance of HttpsProxyAgent from 'https-proxy-agent', as it extends the Agent from 'agent-base' package. So we had to update the condition.

  3. url: new URL(options.url)
    helperOptions.agent = { [options.url.protocol]: helperOptions.agent };
    options.url.protocol string is 'https:', but as the trailing extra column is causing a problem, we had to slice it.

dtadevos and others added 2 commits June 13, 2022 13:54
Hi, 

For private_key_jwt authentication, our Provider, running behind the proxy, tries to retrieve the JWKS keys by the specified jwksUri configured endpoint. 

We pass the proxy agent through httpOptions, as described in the configuration, e.g.:

    httpOptions(urlstr) {
      const options = url.parse('http://proxy-fr-croissy.gemalto.com:8080');
      const agent = new HttpsProxyAgent(options);
      return {
        agent,
        timeout: 5000,
      };
    },

That unfortunatelly didn't work, and the debug undentified 3 issues:

1. const helperOptions = omitBy({ timeout, agent, lookup }, Boolean);
this code omits whatever is provided in httpOptions, so we had to change it to pickBy instead

2. if (!(agent instanceof HttpsAgent) && !(agent instanceof HttpAgent))
this condition is not satisfied when I pass an instance of HttpsProxyAgent from 'https-proxy-agent', as it extends the Agent from 'agent-base' package. So we had to update the condition.

3. url: new URL(options.url)
    helperOptions.agent = { [options.url.protocol]: helperOptions.agent };
options.url.protocol string is 'https:', but as the trailing extra column is causing a problem, we had to slice it.
@panva panva merged commit 80fe961 into panva:main Jun 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants