Skip to content

Commit b9f0e37

Browse files
committed
feat: support hostedName in google OAuth 2.0 provider
Signed-off-by: BoHong Li <raccoon@hackmd.io>
1 parent a6f2ff4 commit b9f0e37

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/auth/google/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ passport.use(new GoogleStrategy({
1717

1818
googleAuth.get('/auth/google', function (req, res, next) {
1919
setReturnToFromReferer(req)
20-
passport.authenticate('google', { scope: ['profile'] })(req, res, next)
20+
passport.authenticate('google', {
21+
scope: ['profile'],
22+
hostedDomain: config.google.hostedDomain
23+
})(req, res, next)
2124
})
2225
// google auth callback
2326
googleAuth.get('/auth/google/callback',

lib/config/default.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ module.exports = {
133133
},
134134
google: {
135135
clientID: undefined,
136-
clientSecret: undefined
136+
clientSecret: undefined,
137+
hostedDomain: undefined
137138
},
138139
ldap: {
139140
providerName: undefined,

lib/config/environment.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ module.exports = {
105105
},
106106
google: {
107107
clientID: process.env.CMD_GOOGLE_CLIENTID,
108-
clientSecret: process.env.CMD_GOOGLE_CLIENTSECRET
108+
clientSecret: process.env.CMD_GOOGLE_CLIENTSECRET,
109+
hostedDomain: process.env.CMD_GOOGLE_HOSTEDDOMAIN
109110
},
110111
ldap: {
111112
providerName: process.env.CMD_LDAP_PROVIDERNAME,

0 commit comments

Comments
 (0)