From cd28397223cfcced549f3ba9dd645f1715106e48 Mon Sep 17 00:00:00 2001 From: Christian Ulrich Date: Thu, 30 Apr 2020 11:56:26 +0200 Subject: [PATCH] additional null checks --- library.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/library.js b/library.js index 17c642d..cd651c1 100644 --- a/library.js +++ b/library.js @@ -38,9 +38,13 @@ params.router.get('/admin/plugins/sso-saml', params.middleware.admin.buildHeader, render); params.router.get('/api/admin/plugins/sso-saml', render); - if (master_config.idp_entry_point !== "" && + if (master_config.idp_entry_point != null && + master_config.idp_entry_point !== "" && + master_config.callback_path != null && master_config.callback_path !== "" && + master_config.issuer != null && master_config.issuer !== "" && + master_config.metadata != null && master_config.metadata !== "") { console.log("creating samlObj"); samlObj = new passportSAML({ @@ -82,9 +86,9 @@ if (samlObj){ - if (master_config.metadata !== "") { + if (master_config.metadata != null && master_config.metadata !== "") { params.router.get(master_config.metadata, function(req, res) { - if (master_config.server_crt !== ""){ + if (master_config.metadata != null && master_config.server_crt !== ""){ var cert = fs.readFileSync(master_config.server_crt, 'utf-8'); res.header("Content-Type", "application/xml"); res.send(samlObj.generateServiceProviderMetadata(cert)) @@ -98,7 +102,8 @@ params.router.post(master_config.callback_path, passport.authenticate('saml'), function(req, res, next){ - if (master_config.login_redirect_url !== ""){ + if (master_config.login_redirect_url != null && + master_config.login_redirect_url !== ""){ res.redirect(master_config.login_redirect_url); } else{ @@ -109,7 +114,8 @@ ); - if (master_config.logout_url !== "") { + if (master_config.logout_url != null && + master_config.logout_url !== "") { params.router.get(master_config.logout_url,function(req,res){ if (req.user && parseInt(req.user.uid, 10) > 0) { @@ -120,7 +126,8 @@ req.logout(); - if (master_config.logout_redirect_url !== ""){ + if (master_config.logout_redirect_url != null && + master_config.logout_redirect_url !== ""){ res.redirect(master_config.logout_redirect_url); } else{