Skip to content

Commit 7fd36b1

Browse files
authored
Add https_proxy support to gitlab oauth (#1296)
Add https_proxy support to gitlab oauth
2 parents 65ecb6d + 2a365d6 commit 7fd36b1

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/web/auth/gitlab/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,24 @@ const GitlabStrategy = require('passport-gitlab2').Strategy
66
const config = require('../../../config')
77
const response = require('../../../response')
88
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
9+
const HttpsProxyAgent = require('https-proxy-agent')
910

1011
const gitlabAuth = module.exports = Router()
1112

12-
passport.use(new GitlabStrategy({
13+
const gitlabAuthStrategy = new GitlabStrategy({
1314
baseURL: config.gitlab.baseURL,
1415
clientID: config.gitlab.clientID,
1516
clientSecret: config.gitlab.clientSecret,
1617
scope: config.gitlab.scope,
1718
callbackURL: config.serverURL + '/auth/gitlab/callback'
18-
}, passportGeneralCallback))
19+
}, passportGeneralCallback)
20+
21+
if (process.env['https_proxy']) {
22+
const httpsProxyAgent = new HttpsProxyAgent(process.env['https_proxy'])
23+
gitlabAuthStrategy._oauth2.setAgent(httpsProxyAgent)
24+
}
25+
26+
passport.use(gitlabAuthStrategy)
1927

2028
gitlabAuth.get('/auth/gitlab', function (req, res, next) {
2129
setReturnToFromReferer(req)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"handlebars": "~4.1.2",
6868
"helmet": "~3.20.0",
6969
"highlight.js": "~9.15.9",
70+
"https-proxy-agent": "^3.0.1",
7071
"i18n": "~0.8.3",
7172
"ionicons": "~2.0.1",
7273
"isomorphic-fetch": "~2.2.1",

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6449,6 +6449,14 @@ https-browserify@^1.0.0:
64496449
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
64506450
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=
64516451

6452+
https-proxy-agent@^3.0.1:
6453+
version "3.0.1"
6454+
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz#b8c286433e87602311b01c8ea34413d856a4af81"
6455+
integrity sha512-+ML2Rbh6DAuee7d07tYGEKOEi2voWPUGan+ExdPbPW6Z3svq+JCqr0v8WmKPOkz1vOVykPCBSuobe7G8GJUtVg==
6456+
dependencies:
6457+
agent-base "^4.3.0"
6458+
debug "^3.1.0"
6459+
64526460
i18n@~0.8.3:
64536461
version "0.8.3"
64546462
resolved "https://registry.yarnpkg.com/i18n/-/i18n-0.8.3.tgz#2d8cf1c24722602c2041d01ba6ae5eaa51388f0e"

0 commit comments

Comments
 (0)