Skip to content

Commit 72c5b0d

Browse files
committed
feat: support customize scope in OAuth2 provider
Signed-off-by: BoHong Li <[email protected]>
1 parent d5d0f3d commit 72c5b0d

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

lib/auth/oauth2/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ passport.use(new OAuth2CustomStrategy({
1515
clientID: config.oauth2.clientID,
1616
clientSecret: config.oauth2.clientSecret,
1717
callbackURL: config.serverURL + '/auth/oauth2/callback',
18-
userProfileURL: config.oauth2.userProfileURL
18+
userProfileURL: config.oauth2.userProfileURL,
19+
scope: config.oauth2.scope
1920
}, passportGeneralCallback))
2021

2122
oauth2Auth.get('/auth/oauth2', function (req, res, next) {

lib/config/default.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ module.exports = {
9898
userProfileURL: undefined,
9999
userProfileUsernameAttr: 'username',
100100
userProfileDisplayNameAttr: 'displayName',
101-
userProfileEmailAttr: 'email'
101+
userProfileEmailAttr: 'email',
102+
scope: 'email'
102103
},
103104
facebook: {
104105
clientID: undefined,

lib/config/environment.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,15 @@ module.exports = {
8888
oauth2: {
8989
providerName: process.env.CMD_OAUTH2_PROVIDERNAME,
9090
baseURL: process.env.CMD_OAUTH2_BASEURL,
91+
clientID: process.env.CMD_OAUTH2_CLIENT_ID,
92+
clientSecret: process.env.CMD_OAUTH2_CLIENT_SECRET,
93+
authorizationURL: process.env.CMD_OAUTH2_AUTHORIZATION_URL,
94+
tokenURL: process.env.CMD_OAUTH2_TOKEN_URL,
9195
userProfileURL: process.env.CMD_OAUTH2_USER_PROFILE_URL,
96+
scope: process.env.CMD_OAUTH2_SCOPE,
9297
userProfileUsernameAttr: process.env.CMD_OAUTH2_USER_PROFILE_USERNAME_ATTR,
9398
userProfileDisplayNameAttr: process.env.CMD_OAUTH2_USER_PROFILE_DISPLAY_NAME_ATTR,
94-
userProfileEmailAttr: process.env.CMD_OAUTH2_USER_PROFILE_EMAIL_ATTR,
95-
tokenURL: process.env.CMD_OAUTH2_TOKEN_URL,
96-
authorizationURL: process.env.CMD_OAUTH2_AUTHORIZATION_URL,
97-
clientID: process.env.CMD_OAUTH2_CLIENT_ID,
98-
clientSecret: process.env.CMD_OAUTH2_CLIENT_SECRET
99+
userProfileEmailAttr: process.env.CMD_OAUTH2_USER_PROFILE_EMAIL_ATTR
99100
},
100101
dropbox: {
101102
clientID: process.env.CMD_DROPBOX_CLIENTID,

0 commit comments

Comments
 (0)