I built my own strategy for passport. Now an instance of my application runs behind a corporate firewall. Thus I need to get all outgoing requests passed to a proxy server first (http), which then connects to the outside world (https). I got this running with other modules like request
which offer an option to pass a proxy config.
`app -(http)-> proxy -(https via vpn tunnel)-> www``
Question
1) How can I force the outgoing requests from my passport strategy to go via the proxy?
2) If it is not possible, to just add the option for passport: How can I get all outgoing requests to use the proxy?
I noticed there is a proxy option in the strategy: https://github.com/jaredhanson/passport-oauth2/blob/master/lib/strategy.js#l110
I tried to extend my strategy and pass this option, but it was not successful.
e.g
Strategy = (options, verify) ->
options = options or {}
options.authorizationURL = options.authorizationURL or 'https://mywebsite.com/oauth2/authorize'
options.tokenURL = options.tokenURL or 'https://mywebsite.com/extern/oauth2/auth_form.aspx'
options.scopeSeparator = options.scopeSeparator or ','
options.proxy = options.proxy or process.env['HTTP_PROXY']
I could solve the problem finally for all outgoing requests:
Code
I extended the global agent which is used as the default setting for all outgoing connections.
Information
https://nodejs.org/api/http.html#http_http_globalagent
Own Proxy for Debugging (JS to easy modify/restart with
gulp-nodemon
)