From 197223dc81267efb22a63872a42f839b2276e1b6 Mon Sep 17 00:00:00 2001 From: ike Date: Fri, 7 Feb 2020 08:51:58 +0800 Subject: Add Google oauth variable: hostedDomain Which is part of `passport-google-oauth2`. It could be used as whitelist to a domain supported by google oauth. Ref: https://github.com/jaredhanson/passport-google-oauth2/issues/3 Signed-off-by: ike --- lib/config/default.js | 3 ++- lib/config/dockerSecret.js | 3 ++- lib/config/environment.js | 3 ++- lib/web/auth/google/index.js | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/config/default.js b/lib/config/default.js index a52a8a4f..ac78e8ed 100644 --- a/lib/config/default.js +++ b/lib/config/default.js @@ -124,7 +124,8 @@ module.exports = { }, google: { clientID: undefined, - clientSecret: undefined + clientSecret: undefined, + hostedDomain: undefined }, ldap: { providerName: undefined, diff --git a/lib/config/dockerSecret.js b/lib/config/dockerSecret.js index 7ff6506f..02b959d9 100644 --- a/lib/config/dockerSecret.js +++ b/lib/config/dockerSecret.js @@ -53,7 +53,8 @@ if (fs.existsSync(basePath)) { }, google: { clientID: getSecret('google_clientID'), - clientSecret: getSecret('google_clientSecret') + clientSecret: getSecret('google_clientSecret'), + hostedDomain: getSecret('google_hostedDomain') }, imgur: getSecret('imgur_clientid') } diff --git a/lib/config/environment.js b/lib/config/environment.js index 944a2fb2..219be499 100644 --- a/lib/config/environment.js +++ b/lib/config/environment.js @@ -101,7 +101,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, diff --git a/lib/web/auth/google/index.js b/lib/web/auth/google/index.js index feb83025..6edf07a9 100644 --- a/lib/web/auth/google/index.js +++ b/lib/web/auth/google/index.js @@ -16,7 +16,7 @@ passport.use(new GoogleStrategy({ }, passportGeneralCallback)) googleAuth.get('/auth/google', function (req, res, next) { - 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', -- cgit v1.2.3