From bac3921197ce7e0598a1e8f5dcbd03b234111959 Mon Sep 17 00:00:00 2001 From: rhtenhove Date: Tue, 8 Oct 2019 18:47:54 +0200 Subject: [PATCH] Add https_proxy support to gitlab oauth Signed-off-by: Ruben ten Hove --- lib/web/auth/gitlab/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/web/auth/gitlab/index.js b/lib/web/auth/gitlab/index.js index 22611eed..f54e2434 100644 --- a/lib/web/auth/gitlab/index.js +++ b/lib/web/auth/gitlab/index.js @@ -6,16 +6,24 @@ const GitlabStrategy = require('passport-gitlab2').Strategy const config = require('../../../config') const response = require('../../../response') const { setReturnToFromReferer, passportGeneralCallback } = require('../utils') +const HttpsProxyAgent = require('https-proxy-agent'); const gitlabAuth = module.exports = Router() -passport.use(new GitlabStrategy({ +let gitlabAuthStrategy = new GitlabStrategy({ baseURL: config.gitlab.baseURL, clientID: config.gitlab.clientID, clientSecret: config.gitlab.clientSecret, scope: config.gitlab.scope, callbackURL: config.serverURL + '/auth/gitlab/callback' -}, passportGeneralCallback)) +}, passportGeneralCallback) + +if (process.env['https_proxy']) { + let httpsProxyAgent = new HttpsProxyAgent(process.env['https_proxy']); + gitlabAuthStrategy._oauth2.setAgent(httpsProxyAgent); +} + +passport.use(gitlabAuthStrategy) gitlabAuth.get('/auth/gitlab', function (req, res, next) { setReturnToFromReferer(req)