Skip to content

Commit bac3921

Browse files
committed
Add https_proxy support to gitlab oauth
Signed-off-by: Ruben ten Hove <git@rhtenhove.nl>
1 parent c9df47d commit bac3921

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-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+
let 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+
let 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)

0 commit comments

Comments
 (0)