Skip to content

Commit

Permalink
fix(auth): Fix session data loss by redirect
Browse files Browse the repository at this point in the history
This patch should fix the broken redirect behaviour of the
authentication provider where users aren't redirected back to the note
they were send off, due to passport forgetting its session.

Reference:
jaredhanson/passport#919

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
  • Loading branch information
SISheogorath committed Jul 19, 2023
1 parent 10a2121 commit 4f6fba7
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/web/auth/email/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ emailAuth.post('/login', urlencodedParser, function (req, res, next) {
passport.authenticate('local', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/',
failureFlash: 'Invalid email or password.'
failureFlash: 'Invalid email or password.',
keepSessionInfo: true
})(req, res, next)
})
3 changes: 2 additions & 1 deletion lib/web/auth/facebook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ facebookAuth.get('/auth/facebook', function (req, res, next) {
facebookAuth.get('/auth/facebook/callback',
passport.authenticate('facebook', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
failureRedirect: config.serverURL + '/',
keepSessionInfo: true
})
)
3 changes: 2 additions & 1 deletion lib/web/auth/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ githubAuth.get('/auth/github', function (req, res, next) {
githubAuth.get('/auth/github/callback',
passport.authenticate('github', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
failureRedirect: config.serverURL + '/',
keepSessionInfo: true
})
)

Expand Down
3 changes: 2 additions & 1 deletion lib/web/auth/gitlab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ gitlabAuth.get('/auth/gitlab', function (req, res, next) {
gitlabAuth.get('/auth/gitlab/callback',
passport.authenticate('gitlab', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
failureRedirect: config.serverURL + '/',
keepSessionInfo: true
})
)

Expand Down
3 changes: 2 additions & 1 deletion lib/web/auth/google/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ googleAuth.get('/auth/google', function (req, res, next) {
googleAuth.get('/auth/google/callback',
passport.authenticate('google', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
failureRedirect: config.serverURL + '/',
keepSessionInfo: true
})
)
3 changes: 2 additions & 1 deletion lib/web/auth/ldap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ ldapAuth.post('/auth/ldap', urlencodedParser, function (req, res, next) {
passport.authenticate('ldapauth', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/',
failureFlash: true
failureFlash: true,
keepSessionInfo: true
})(req, res, next)
})
3 changes: 2 additions & 1 deletion lib/web/auth/mattermost/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ mattermostAuth.get('/auth/mattermost', function (req, res, next) {
mattermostAuth.get('/auth/mattermost/callback',
passport.authenticate('oauth2', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
failureRedirect: config.serverURL + '/',
keepSessionInfo: true
})
)
3 changes: 2 additions & 1 deletion lib/web/auth/oauth2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ oauth2Auth.get('/auth/oauth2', function (req, res, next) {
oauth2Auth.get('/auth/oauth2/callback',
passport.authenticate('oauth2', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
failureRedirect: config.serverURL + '/',
keepSessionInfo: true
})
)
3 changes: 2 additions & 1 deletion lib/web/auth/openid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ openIDAuth.post('/auth/openid', urlencodedParser, function (req, res, next) {
openIDAuth.get('/auth/openid/callback',
passport.authenticate('openid', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
failureRedirect: config.serverURL + '/',
keepSessionInfo: true
})
)
3 changes: 2 additions & 1 deletion lib/web/auth/saml/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ samlAuth.get('/auth/saml',
samlAuth.post('/auth/saml/callback', urlencodedParser,
passport.authenticate('saml', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
failureRedirect: config.serverURL + '/',
keepSessionInfo: true
})
)

Expand Down
3 changes: 2 additions & 1 deletion lib/web/auth/twitter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ twitterAuth.get('/auth/twitter', function (req, res, next) {
twitterAuth.get('/auth/twitter/callback',
passport.authenticate('twitter', {
successReturnToOrRedirect: config.serverURL + '/',
failureRedirect: config.serverURL + '/'
failureRedirect: config.serverURL + '/',
keepSessionInfo: true
})
)

0 comments on commit 4f6fba7

Please sign in to comment.