{"action":"created","issue":{"url":"https://api.github.com/repos/AzureAD/passport-azure-ad/issues/341","repository_url":"https://api.github.com/repos/AzureAD/passport-azure-ad","labels_url":"https://api.github.com/repos/AzureAD/passport-azure-ad/issues/341/labels{/name}","comments_url":"https://api.github.com/repos/AzureAD/passport-azure-ad/issues/341/comments","events_url":"https://api.github.com/repos/AzureAD/passport-azure-ad/issues/341/events","html_url":"https://github.com/AzureAD/passport-azure-ad/issues/341","id":264434089,"node_id":"MDU6SXNzdWUyNjQ0MzQwODk=","number":341,"title":"Cannot connect behind proxy","user":{"login":"hsimah","id":10041901,"node_id":"MDQ6VXNlcjEwMDQxOTAx","avatar_url":"https://avatars2.githubusercontent.com/u/10041901?v=4","gravatar_id":"","url":"https://api.github.com/users/hsimah","html_url":"https://github.com/hsimah","followers_url":"https://api.github.com/users/hsimah/followers","following_url":"https://api.github.com/users/hsimah/following{/other_user}","gists_url":"https://api.github.com/users/hsimah/gists{/gist_id}","starred_url":"https://api.github.com/users/hsimah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hsimah/subscriptions","organizations_url":"https://api.github.com/users/hsimah/orgs","repos_url":"https://api.github.com/users/hsimah/repos","events_url":"https://api.github.com/users/hsimah/events{/privacy}","received_events_url":"https://api.github.com/users/hsimah/received_events","type":"User","site_admin":false},"labels":[{"id":40395343,"node_id":"MDU6TGFiZWw0MDM5NTM0Mw==","url":"https://api.github.com/repos/AzureAD/passport-azure-ad/labels/enhancement","name":"enhancement","color":"eb6420","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-10-11T02:06:45Z","updated_at":"2018-11-13T18:11:45Z","closed_at":null,"author_association":"NONE","body":"I develop behind a corporate proxy - this library does not set the agent on any requests to Azure.\r\n\r\nI need to get this done for an internal project and so have forked the repo and added in a quick and dirty `https-proxy-agent` import to `oidcstrategy` and `metadata`. I will hopefully come back later and clean it up. "},"comment":{"url":"https://api.github.com/repos/AzureAD/passport-azure-ad/issues/comments/438378097","html_url":"https://github.com/AzureAD/passport-azure-ad/issues/341#issuecomment-438378097","issue_url":"https://api.github.com/repos/AzureAD/passport-azure-ad/issues/341","id":438378097,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODM3ODA5Nw==","user":{"login":"mplwork","id":43606815,"node_id":"MDQ6VXNlcjQzNjA2ODE1","avatar_url":"https://avatars0.githubusercontent.com/u/43606815?v=4","gravatar_id":"","url":"https://api.github.com/users/mplwork","html_url":"https://github.com/mplwork","followers_url":"https://api.github.com/users/mplwork/followers","following_url":"https://api.github.com/users/mplwork/following{/other_user}","gists_url":"https://api.github.com/users/mplwork/gists{/gist_id}","starred_url":"https://api.github.com/users/mplwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mplwork/subscriptions","organizations_url":"https://api.github.com/users/mplwork/orgs","repos_url":"https://api.github.com/users/mplwork/repos","events_url":"https://api.github.com/users/mplwork/events{/privacy}","received_events_url":"https://api.github.com/users/mplwork/received_events","type":"User","site_admin":false},"created_at":"2018-11-13T18:11:45Z","updated_at":"2018-11-13T18:11:45Z","author_association":"NONE","body":"I am still fighting this. This whole issue is a real pain but I made some progress.\r\n\r\nI had to change `package.json` (and use portable git instead of Cygwin's as npm messes up paths) to\r\n\r\n```\r\n \"passport-azure-ad\": \"hsimah/passport-azure-ad#feature/add_proxy_support\"\r\n```\r\nas @hsimah 's patch lives in a branch. Unfortunately, the patch doesn't pick up the proxy setting from the usual env variables so I had to change `app.js`:\r\n\r\n```\r\n@@ -119,6 +126,8 @@ passport.use(new OIDCStrategy({\r\n     useCookieInsteadOfSession: config.creds.useCookieInsteadOfSession,\r\n     cookieEncryptionKeys: config.creds.cookieEncryptionKeys,\r\n     clockSkew: config.creds.clockSkew,\r\n+    loggingNoPII: false,\r\n+    proxy: { port: 8888, host: 'localhost', protocol: 'http' }\r\n   },\r\n   function(iss, sub, profile, accessToken, refreshToken, done) {\r\n     if (!profile.oid) {\r\n```\r\n\r\nNow the proxy is used, hurray! But it still doesn't work:\r\n\r\n```\r\n::1 - - [13/Nov/2018:17:52:32 +0000] \"POST /auth/openid/return HTTP/1.1\" 302 46 \"-\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0\"\r\n{\"name\":\"AzureAD: OIDC Passport Strategy\",\"hostname\":\"p01166818\",\"pid\":12224,\"level\":30,\"msg\":\"authentication failed due to: In _authCodeFlowHandler: failed to redeem authorization code: read ECONNRESET\",\"time\":\"2018-11-13T17:52:32.334Z\",\"v\":0}\r\n_http_outgoing.js:491\r\n    throw new Error('Can\\'t set headers after they are sent.');\r\n    ^\r\n\r\nError: Can't set headers after they are sent.\r\n    at validateHeader (_http_outgoing.js:491:11)\r\n    at ServerResponse.setHeader (_http_outgoing.js:498:3)\r\n    at ServerResponse.res.setHeader (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\connect\\lib\\patch.js:134:22)\r\n    at ServerResponse.res.set.res.header (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\express\\lib\\response.js:595:10)\r\n    at ServerResponse.res.location (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\express\\lib\\response.js:725:8)\r\n    at ServerResponse.res.redirect (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\express\\lib\\response.js:764:8)\r\n    at allFailed (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\passport\\lib\\middleware\\authenticate.js:145:20)\r\n    at attempt (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\passport\\lib\\middleware\\authenticate.js:180:28)\r\n    at Strategy.strategy.fail (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\passport\\lib\\middleware\\authenticate.js:297:9)\r\n    at Strategy.failWithLog (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\passport-azure-ad\\lib\\oidcstrategy.js:1490:15)\r\n    at async.waterfall (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\passport-azure-ad\\lib\\oidcstrategy.js:651:21)\r\n    at C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\passport-azure-ad\\node_modules\\async\\lib\\async.js:52:16\r\n    at C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\passport-azure-ad\\node_modules\\async\\lib\\async.js:1209:30\r\n    at self._getAccessTokenBySecretOrAssertion (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\passport-azure-ad\\lib\\oidcstrategy.js:1197:16)\r\n    at oauth2._request (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\passport-azure-ad\\lib\\oidcstrategy.js:1470:16)\r\n    at ClientRequest.<anonymous> (C:\\O365\\botsample\\AppModelv2-WebApp-OpenIDConnect-nodejs\\node_modules\\oauth\\lib\\oauth2.js:162:5)\r\n    at emitOne (events.js:116:13)\r\n    at ClientRequest.emit (events.js:211:7)\r\n    at TLSSocket.socketErrorListener (_http_client.js:387:9)\r\n    at emitOne (events.js:116:13)\r\n    at TLSSocket.emit (events.js:211:7)\r\n    at emitErrorNT (internal/streams/destroy.js:66:8)\r\n```\r\n\r\nI get a similar result if I use `global-tunnel-ng` instead of the patched `passport-azure-ad`.  What's next to hack?"}}
{"actor":{"display_login":"mplwork"}}