From b9f0e37eee93cc0a5666c8b73eedcbd7294e66e4 Mon Sep 17 00:00:00 2001 From: BoHong Li Date: Fri, 28 Feb 2020 17:17:10 +0800 Subject: [PATCH] feat: support hostedName in google OAuth 2.0 provider Signed-off-by: BoHong Li --- lib/auth/google/index.js | 5 ++++- lib/config/default.js | 3 ++- lib/config/environment.js | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/auth/google/index.js b/lib/auth/google/index.js index 59d1ca2c..280a08cc 100644 --- a/lib/auth/google/index.js +++ b/lib/auth/google/index.js @@ -17,7 +17,10 @@ passport.use(new GoogleStrategy({ googleAuth.get('/auth/google', function (req, res, next) { setReturnToFromReferer(req) - passport.authenticate('google', { scope: ['profile'] })(req, res, next) + passport.authenticate('google', { + scope: ['profile'], + hostedDomain: config.google.hostedDomain + })(req, res, next) }) // google auth callback googleAuth.get('/auth/google/callback', diff --git a/lib/config/default.js b/lib/config/default.js index 12324680..b4b7e846 100644 --- a/lib/config/default.js +++ b/lib/config/default.js @@ -133,7 +133,8 @@ module.exports = { }, google: { clientID: undefined, - clientSecret: undefined + clientSecret: undefined, + hostedDomain: undefined }, ldap: { providerName: undefined, diff --git a/lib/config/environment.js b/lib/config/environment.js index e46c58f1..c86007c3 100644 --- a/lib/config/environment.js +++ b/lib/config/environment.js @@ -105,7 +105,8 @@ module.exports = { }, google: { clientID: process.env.CMD_GOOGLE_CLIENTID, - clientSecret: process.env.CMD_GOOGLE_CLIENTSECRET + clientSecret: process.env.CMD_GOOGLE_CLIENTSECRET, + hostedDomain: process.env.CMD_GOOGLE_HOSTEDDOMAIN }, ldap: { providerName: process.env.CMD_LDAP_PROVIDERNAME,