Skip to content

Commit 6dd3d92

Browse files
authored
feat: add state parameter to OAuth strategies for enhanced security (#1902)
2 parents cf53ce1 + e0fb494 commit 6dd3d92

File tree

7 files changed

+14
-7
lines changed

7 files changed

+14
-7
lines changed

lib/auth/bitbucket/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const bitbucketAuth = module.exports = Router()
1111
passport.use(new BitbucketStrategy({
1212
clientID: config.bitbucket.clientID,
1313
clientSecret: config.bitbucket.clientSecret,
14-
callbackURL: config.serverURL + '/auth/bitbucket/callback'
14+
callbackURL: config.serverURL + '/auth/bitbucket/callback',
15+
state: true
1516
}, passportGeneralCallback))
1617

1718
bitbucketAuth.get('/auth/bitbucket', function (req, res, next) {

lib/auth/dropbox/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ passport.use(new DropboxStrategy({
1212
apiVersion: '2',
1313
clientID: config.dropbox.clientID,
1414
clientSecret: config.dropbox.clientSecret,
15-
callbackURL: config.serverURL + '/auth/dropbox/callback'
15+
callbackURL: config.serverURL + '/auth/dropbox/callback',
16+
state: true
1617
}, passportGeneralCallback))
1718

1819
dropboxAuth.get('/auth/dropbox', function (req, res, next) {

lib/auth/facebook/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const facebookAuth = module.exports = Router()
1212
passport.use(new FacebookStrategy({
1313
clientID: config.facebook.clientID,
1414
clientSecret: config.facebook.clientSecret,
15-
callbackURL: config.serverURL + '/auth/facebook/callback'
15+
callbackURL: config.serverURL + '/auth/facebook/callback',
16+
state: true
1617
}, passportGeneralCallback))
1718

1819
facebookAuth.get('/auth/facebook', function (req, res, next) {

lib/auth/github/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ passport.use(new GithubStrategy({
2626
callbackURL: config.serverURL + '/auth/github/callback',
2727
authorizationURL: githubUrl('login/oauth/authorize'),
2828
tokenURL: githubUrl('login/oauth/access_token'),
29-
userProfileURL: githubUrl('api/v3/user')
29+
userProfileURL: githubUrl('api/v3/user'),
30+
state: true
3031
}, async (accessToken, refreshToken, profile, done) => {
3132
if (!config.github.organizations) {
3233
return passportGeneralCallback(accessToken, refreshToken, profile, done)

lib/auth/gitlab/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const gitlabAuthStrategy = new GitlabStrategy({
1515
clientID: config.gitlab.clientID,
1616
clientSecret: config.gitlab.clientSecret,
1717
scope: config.gitlab.scope,
18-
callbackURL: config.serverURL + '/auth/gitlab/callback'
18+
callbackURL: config.serverURL + '/auth/gitlab/callback',
19+
state: true
1920
}, passportGeneralCallback)
2021

2122
if (process.env.https_proxy) {

lib/auth/google/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ passport.use(new GoogleStrategy({
1212
clientID: config.google.clientID,
1313
clientSecret: config.google.clientSecret,
1414
callbackURL: config.serverURL + '/auth/google/callback',
15-
userProfileURL: 'https://www.googleapis.com/oauth2/v3/userinfo'
15+
userProfileURL: 'https://www.googleapis.com/oauth2/v3/userinfo',
16+
state: true
1617
}, passportGeneralCallback))
1718

1819
googleAuth.get('/auth/google', function (req, res, next) {

lib/auth/twitter/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const twitterAuth = module.exports = Router()
1212
passport.use(new TwitterStrategy({
1313
consumerKey: config.twitter.consumerKey,
1414
consumerSecret: config.twitter.consumerSecret,
15-
callbackURL: config.serverURL + '/auth/twitter/callback'
15+
callbackURL: config.serverURL + '/auth/twitter/callback',
16+
state: true
1617
}, passportGeneralCallback))
1718

1819
twitterAuth.get('/auth/twitter', function (req, res, next) {

0 commit comments

Comments
 (0)