From a8f0a06b6cbffbe82870da94d1726683336856ea Mon Sep 17 00:00:00 2001 From: Florian Nari Date: Wed, 9 Oct 2024 16:08:05 +0200 Subject: [PATCH] fix #30 avoid double slash in CAS logout redirect URL --- server/routes.js | 7 ++++++- server/routes/pagesRoutes.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/routes.js b/server/routes.js index 9f21744..746caa5 100644 --- a/server/routes.js +++ b/server/routes.js @@ -56,7 +56,12 @@ module.exports = function(_passport) { done(null, user); }); - passport.use(new(require('passport-apereo-cas').Strategy)(properties.esup.CAS, function(profile, done) { + const CAS = properties.esup.CAS; + if (!CAS.casBaseURL.endsWith('/')) { + CAS.casBaseURL += "/"; + } + + passport.use(new(require('passport-apereo-cas').Strategy)(CAS, function(profile, done) { // console.log("profile : " + JSON.stringify(profile, null ,2)); return done(null, {uid:profile.user, attributes:profile.attributes}); })); diff --git a/server/routes/pagesRoutes.js b/server/routes/pagesRoutes.js index 3a406a1..025e6bb 100644 --- a/server/routes/pagesRoutes.js +++ b/server/routes/pagesRoutes.js @@ -64,7 +64,7 @@ exports.routing = function(router, passport) { router.get('/logout', function(req, res, next) { req.logout(function(err) { if (err) { return next(err); } - res.redirect(properties.esup.CAS.casBaseURL + '/logout'); + res.redirect(properties.esup.CAS.casBaseURL + 'logout'); }); }); } \ No newline at end of file