From e0a88727423dfdb24e09f4e7e69cae718a7de127 Mon Sep 17 00:00:00 2001 From: Ralph Krimmel Date: Thu, 28 Nov 2019 10:59:59 +0100 Subject: Moving the storage of referrer information to main authorization check instead of doing it in the authentication source Signed-off-by: Ralph Krimmel --- lib/errors.js | 2 ++ lib/web/auth/saml/index.js | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/errors.js b/lib/errors.js index 64f93859..56fb7027 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -6,6 +6,8 @@ module.exports = { if (req.user) { responseError(res, '403', 'Forbidden', 'oh no.') } else { + if (!req.session) req.session = {} + req.session.returnTo = req.originalUrl || config.serverUrl + '/'; req.flash('error', 'You are not allowed to access this page. Maybe try logging in?') res.redirect(config.serverURL + '/') } diff --git a/lib/web/auth/saml/index.js b/lib/web/auth/saml/index.js index dd274814..40a6f8b3 100644 --- a/lib/web/auth/saml/index.js +++ b/lib/web/auth/saml/index.js @@ -7,7 +7,6 @@ const config = require('../../../config') const models = require('../../../models') const logger = require('../../../logger') const { urlencodedParser } = require('../../utils') -const { setReturnToFromReferer } = require('../utils') const fs = require('fs') const intersection = function (array1, array2) { return array1.filter((n) => array2.includes(n)) } @@ -77,13 +76,12 @@ passport.use(new SamlStrategy({ }) })) -samlAuth.get('/auth/saml', function (req, res, next) { - setReturnToFromReferer(req) +samlAuth.get('/auth/saml', passport.authenticate('saml', { successReturnToOrRedirect: config.serverURL + '/', failureRedirect: config.serverURL + '/' - })(req, res, next) -}) + }) +) samlAuth.post('/auth/saml/callback', urlencodedParser, passport.authenticate('saml', { -- cgit v1.2.3