From 1881775379d9d1a358d1dc9762524723cc005673 Mon Sep 17 00:00:00 2001 From: foobarable Date: Wed, 27 Nov 2019 10:50:14 +0100 Subject: Fixing redirection after SAML login Saving referer into session in SAML auth so passport can redirect correctly after SAML login. Signed-off-by: Ralph Krimmel --- lib/web/auth/saml/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/web') diff --git a/lib/web/auth/saml/index.js b/lib/web/auth/saml/index.js index 40a6f8b3..1c80c934 100644 --- a/lib/web/auth/saml/index.js +++ b/lib/web/auth/saml/index.js @@ -7,6 +7,7 @@ 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)) } @@ -76,11 +77,13 @@ passport.use(new SamlStrategy({ }) })) -samlAuth.get('/auth/saml', +samlAuth.get('/auth/saml',function(req,res,next) { + setReturnToFromReferer(req) passport.authenticate('saml', { successReturnToOrRedirect: config.serverURL + '/', failureRedirect: config.serverURL + '/' - }) + })(req,res,next) + } ) samlAuth.post('/auth/saml/callback', urlencodedParser, -- cgit v1.2.3