Added warning if NodeJS version does not support OpenID.

Ylian Saint-Hilaire committed Sep 6, 2022 at 14:40 UTC c8335f94d44bd5acf3848299d1ff0faf927cd1bb
2 files changed +19 -4
meshcentral.js
+15 -2
@@ -3860,7 +3860,12 @@ var ServerWarnings = {
3860 17: "SendGrid server has limited use in LAN mode.",
3861 18: "SMTP server has limited use in LAN mode.",
3862 19: "SMS gateway has limited use in LAN mode.",
3863 - 20: "Invalid \"LoginCookieEncryptionKey\" in config.json."
3863 + 20: "Invalid \"LoginCookieEncryptionKey\" in config.json.",
3864 + 21: "Backup path can't be set within meshcentral-data folder, backup settings ignored.",
3865 + 22: "Failed to sign agent {0}: {1}",
3866 + 23: "Unable to load agent icon file: {0}.",
3867 + 24: "Unable to load agent logo file: {0}.",
3868 + 25: "This NodeJS version does not support OpenID."
3869 };
3870 */
3871
@@ -3941,7 +3946,15 @@ function mainStart() {
3946 if ((typeof config.domains[i].authstrategies.github == 'object') && (typeof config.domains[i].authstrategies.github.clientid == 'string') && (typeof config.domains[i].authstrategies.github.clientsecret == 'string') && (passport.indexOf('passport-github2') == -1)) { passport.push('passport-github2'); }
3947 if ((typeof config.domains[i].authstrategies.reddit == 'object') && (typeof config.domains[i].authstrategies.reddit.clientid == 'string') && (typeof config.domains[i].authstrategies.reddit.clientsecret == 'string') && (passport.indexOf('passport-reddit') == -1)) { passport.push('passport-reddit'); }
3948 if ((typeof config.domains[i].authstrategies.azure == 'object') && (typeof config.domains[i].authstrategies.azure.clientid == 'string') && (typeof config.domains[i].authstrategies.azure.clientsecret == 'string') && (typeof config.domains[i].authstrategies.azure.tenantid == 'string') && (passport.indexOf('passport-azure-oauth2') == -1)) { passport.push('passport-azure-oauth2'); passport.push('jwt-simple'); }
3944 - if ((typeof config.domains[i].authstrategies.oidc == 'object') && (typeof config.domains[i].authstrategies.oidc.clientid == 'string') && (typeof config.domains[i].authstrategies.oidc.clientsecret == 'string') && (typeof config.domains[i].authstrategies.oidc.issuer == 'string') && (passport.indexOf('@mstrhakr/passport-openidconnect') == -1)) { passport.push('@mstrhakr/passport-openidconnect'); passport.push('openid-client'); }
3949 + if ((typeof config.domains[i].authstrategies.oidc == 'object') && (typeof config.domains[i].authstrategies.oidc.clientid == 'string') && (typeof config.domains[i].authstrategies.oidc.clientsecret == 'string') && (typeof config.domains[i].authstrategies.oidc.issuer == 'string') && (passport.indexOf('@mstrhakr/passport-openidconnect') == -1)) {
3950 + if ((nodeVersion >= 17) || ((Math.floor(nodeVersion) == 16) && (nodeVersion >= 16.13)) || ((Math.floor(nodeVersion) == 14) && (nodeVersion >= 14.15)) || ((Math.floor(nodeVersion) == 12) && (nodeVersion >= 12.19))) {
3951 + passport.push('@mstrhakr/passport-openidconnect');
3952 + passport.push('openid-client');
3953 + } else {
3954 + addServerWarning('This NodeJS version does not support OpenID.', 25);
3955 + delete config.domains[i].authstrategies.oidc;
3956 + }
3957 + }
3958 if ((typeof config.domains[i].authstrategies.saml == 'object') || (typeof config.domains[i].authstrategies.jumpcloud == 'object')) { passport.push('passport-saml'); }
3959 }
3960 if (config.domains[i].sessionrecording != null) { sessionRecording = true; }
views/default.handlebars
+4 -2
@@ -2322,6 +2322,7 @@
2322 break;
2323 }
2324 case 'serverwarnings': {
2325 + console.log(message);
2326 if ((message.warnings != null) && (message.warnings.length > 0)) {
2327 var ServerWarnings = {
2328 1: "MeshCentral SSH support requires NodeJS 11 or higher.",
@@ -2347,7 +2348,8 @@
2348 21: "Backup path can't be set within meshcentral-data folder, backup settings ignored.",
2349 22: "Failed to sign agent {0}: {1}",
2350 23: "Unable to load agent icon file: {0}.",
2350 - 24: "Unable to load agent logo file: {0}."
2351 + 24: "Unable to load agent logo file: {0}.",
2352 + 25: "This NodeJS version does not support OpenID."
2353 };
2354 var x = '';
2355 for (var i in message.warnings) {
@@ -2356,7 +2358,7 @@
2358 x += '<div style=color:red;padding-bottom:6px><b>' + "WARNING: " + y + '</b></div>';
2359 } else {
2360 var z = ServerWarnings[y.id];
2359 - if (z == null) { z = y.msg; } else { z = format(z, ...y.args); }
2361 + if (z == null) { z = y.msg; } else { if (y.args != null) { z = format(z, ...y.args); } }
2362 x += '<div style=color:red;padding-bottom:6px><b>' + "WARNING: " + z + '</b></div>';
2363 }
2364 }