jaredhanson / passport-openidconnect

OpenID Connect authentication strategy for Passport and Node.js.
https://www.passportjs.org/packages/passport-openidconnect/?utm_source=github&utm_medium=referral&utm_campaign=passport-openidconnect&utm_content=about
MIT License
188 stars 173 forks source link

Proxy issue on OAuth2 - ENETUNREACH failed to obtain access token #97

Open rajasekar-mu opened 1 year ago

rajasekar-mu commented 1 year ago

I have added below proxy options referred at - #https://github.com/jaredhanson/passport-oauth2/issues/59

const agent = new HttpsProxyAgent(process.env.HTTP_PROXY); gStrategy._oauth2.setAgent(agent); passport.use(gStrategy);

but its not working, so directly added proxy on node_modules/oauth/lib/oauth2.js for workaround.

var queryStr= querystring.stringify(parsedUrl.query); if( queryStr ) queryStr= "?" + queryStr; httpsProxyAgent = new HttpsProxyAgent(process.env.HTTP_PROXY) var options = { host:parsedUrl.hostname, port: parsedUrl.port, path: parsedUrl.pathname + queryStr, method: method, headers: realHeaders }; options.agent = httpsProxyAgent; this._executeRequest( http_library, options, post_body, callback ); }

Any permanent fix is available? Every time we cant change the node_modules inside the Docker container. Kindly provide fixes.

david114 commented 1 year ago

have you found a solution to this problem?

rajasekar-mu commented 1 year ago

Not get permanent fix, still using workaround method

Add additional (Proxy) options request generation in below path,

node_modules/oauth/lib/oauth2.js

httpsProxyAgent = new HttpsProxyAgent(process.env.HTTP_PROXY) options.agent = httpsProxyAgent; this._executeRequest( http_library, options, post_body, callback );