Removed Reddit auth strategy since it never worked well.

Ylian Saint-Hilaire committed Mar 3, 2024 at 16:34 UTC bab35e7bca49db0202e88268544caad21376c549
8 files changed +4 -98
meshcentral-config-schema.json
-35
@@ -2860,41 +2860,6 @@
2860 "clientsecret"
2861 ]
2862 },
2863 - "reddit": {
2864 - "type": "object",
2865 - "properties": {
2866 - "callbackurl": {
2867 - "type": "string",
2868 - "format": "uri"
2869 - },
2870 - "newAccounts": {
2871 - "type": "boolean",
2872 - "default": false
2873 - },
2874 - "newAccountsUserGroups": {
2875 - "type": "array",
2876 - "uniqueItems": true,
2877 - "items": {
2878 - "type": "string"
2879 - }
2880 - },
2881 - "clientid": {
2882 - "type": "string"
2883 - },
2884 - "clientsecret": {
2885 - "type": "string"
2886 - },
2887 - "logouturl": {
2888 - "type": "string",
2889 - "format": "uri",
2890 - "description": "Then set, the user will be redirected to this URL when hitting the logout link."
2891 - }
2892 - },
2893 - "required": [
2894 - "clientid",
2895 - "clientsecret"
2896 - ]
2897 - },
2863 "azure": {
2864 "type": "object",
2865 "properties": {
meshcentral.js
-1
@@ -4005,7 +4005,6 @@ function mainStart() {
4005 if ((typeof config.domains[i].authstrategies.twitter == 'object') && (typeof config.domains[i].authstrategies.twitter.clientid == 'string') && (typeof config.domains[i].authstrategies.twitter.clientsecret == 'string') && (passport.indexOf('passport-twitter') == -1)) { passport.push('passport-twitter'); }
4006 if ((typeof config.domains[i].authstrategies.google == 'object') && (typeof config.domains[i].authstrategies.google.clientid == 'string') && (typeof config.domains[i].authstrategies.google.clientsecret == 'string') && (passport.indexOf('passport-google-oauth20') == -1)) { passport.push('passport-google-oauth20'); }
4007 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'); }
4008 - 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'); }
4008 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'); }
4009 if ((typeof config.domains[i].authstrategies.oidc == 'object') && (passport.indexOf('openid-client') == -1)) {
4010 if ((nodeVersion >= 17)
sample-config-advanced.json
-7
@@ -485,13 +485,6 @@
485 "clientid": "xxxxxxxxxxxxxxxxxxxxxxx",
486 "clientsecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
487 },
488 - "reddit": {
489 - "_callbackurl": "https://server/auth-reddit-callback",
490 - "newAccounts": true,
491 - "_newAccountsUserGroups": [ "ugrp//xxxxxxxxxxxxxxxxx" ],
492 - "clientid": "xxxxxxxxxxxxxxxxxxxxxxx",
493 - "clientsecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
494 - },
488 "azure": {
489 "_callbackurl": "https://server/auth-azure-callback",
490 "newAccounts": true,
views/default.handlebars
-1
@@ -16295,7 +16295,6 @@
16295 if (shortuserid.startsWith('~twitter:')) { QV('p30userAuthServiceLogo', true); Q('p30userAuthServiceLogo').src = 'images/login/twitter64.png'; }
16296 else if (shortuserid.startsWith('~google:')) { QV('p30userAuthServiceLogo', true); Q('p30userAuthServiceLogo').src = 'images/login/google64.png'; }
16297 else if (shortuserid.startsWith('~github:')) { QV('p30userAuthServiceLogo', true); Q('p30userAuthServiceLogo').src = 'images/login/github64.png'; }
16298 - else if (shortuserid.startsWith('~reddit:')) { QV('p30userAuthServiceLogo', true); Q('p30userAuthServiceLogo').src = 'images/login/reddit64.png'; }
16298 else if (shortuserid.startsWith('~azure:')) { QV('p30userAuthServiceLogo', true); Q('p30userAuthServiceLogo').src = 'images/login/azure64.png'; }
16299 else if (shortuserid.startsWith('~oidc:')) { QV('p30userAuthServiceLogo', true); Q('p30userAuthServiceLogo').src = 'images/login/oidc64.png'; }
16300 else if (shortuserid.startsWith('~jumpcloud:')) { QV('p30userAuthServiceLogo', true); Q('p30userAuthServiceLogo').src = 'images/login/jumpcloud64.png'; }
views/login-mobile.handlebars
+3 -5
@@ -88,11 +88,10 @@
88 <a id="auth-twitter" href="auth-twitter" style="display:none"><img src="images/login/twitter32.png" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Twitter" /></a>
89 <a id="auth-google" href="auth-google" style="display:none"><img src="images/login/google32.png" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Google" /></a>
90 <a id="auth-github" href="auth-github" style="display:none"><img src="images/login/github32.png" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using GitHub" /></a>
91 - <a id="auth-reddit" href="auth-reddit" style="display:none"><img src="images/login/reddit32.png" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Reddit" /></a>
91 <a id="auth-azure" href="auth-azure" style="display:none"><img src="images/login/azure32.png" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Azure" /></a>
93 - <a id="auth-oidc" href="auth-oidc" style="display:none"><img src="images/login/oidc32.png" srcset="images/login/oidc64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using OpenID Connect" /></a>
94 - <a id="auth-oidc-azure" href="auth-oidc" style="display:none"><img src="images/login/azure32.png" srcset="images/login/azure64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in with Azure using OpenID Connect" /></a>
95 - <a id="auth-oidc-google" href="auth-oidc" style="display:none"><img src="images/login/google32.png" srcset="images/login/google64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in with Google using OpenID Connect" /></a>
92 + <a id="auth-oidc" href="auth-oidc" style="display:none"><img src="images/login/oidc32.png" srcset="images/login/oidc64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using OpenID Connect" /></a>
93 + <a id="auth-oidc-azure" href="auth-oidc" style="display:none"><img src="images/login/azure32.png" srcset="images/login/azure64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in with Azure using OpenID Connect" /></a>
94 + <a id="auth-oidc-google" href="auth-oidc" style="display:none"><img src="images/login/google32.png" srcset="images/login/google64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in with Google using OpenID Connect" /></a>
95 <a id="auth-jumpcloud" href="auth-jumpcloud" style="display:none"><img src="images/login/jumpcloud32.png" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using JumpCloud" /></a>
96 <a id="auth-intel" href="auth-intel" style="display:none"><img src="images/login/intel32.png" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Intel" /></a>
97 <a id="auth-saml" href="auth-saml" style="display:none"><img src="images/login/generic32.png" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Single Sign-in" /></a>
@@ -399,7 +398,6 @@
398 if (authStrategies.indexOf('twitter') >= 0) { QV('auth-twitter', true); }
399 if (authStrategies.indexOf('google') >= 0) { QV('auth-google', true); }
400 if (authStrategies.indexOf('github') >= 0) { QV('auth-github', true); }
402 - if (authStrategies.indexOf('reddit') >= 0) { QV('auth-reddit', true); }
401 if (authStrategies.indexOf('azure') >= 0) { QV('auth-azure', true); }
402 if (authStrategies.indexOf('oidc') >= 0) { QV('auth-oidc', true); }
403 if (authStrategies.indexOf('oidc-azure') >= 0) { QV('auth-oidc-azure', true); }
views/login.handlebars
-2
@@ -81,7 +81,6 @@
81 <a id="auth-twitter" href="auth-twitter" style="display:none"><img src="images/login/twitter32.png" srcset="images/login/twitter64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Twitter" /></a>
82 <a id="auth-google" href="auth-google" style="display:none"><img src="images/login/google32.png" srcset="images/login/google64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Google" /></a>
83 <a id="auth-github" href="auth-github" style="display:none"><img src="images/login/github32.png" srcset="images/login/github64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using GitHub" /></a>
84 - <a id="auth-reddit" href="auth-reddit" style="display:none"><img src="images/login/reddit32.png" srcset="images/login/reddit64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Reddit" /></a>
84 <a id="auth-azure" href="auth-azure" style="display:none"><img src="images/login/azure32.png" srcset="images/login/azure64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Azure" /></a>
85 <a id="auth-oidc" href="auth-oidc" style="display:none"><img src="images/login/oidc32.png" srcset="images/login/oidc64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using OpenID Connect" /></a>
86 <a id="auth-oidc-azure" href="auth-oidc" style="display:none"><img src="images/login/azure32.png" srcset="images/login/azure64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in with Azure using OpenID Connect" /></a>
@@ -424,7 +423,6 @@
423 if (authStrategies.indexOf('twitter') >= 0) { QV('auth-twitter', true); }
424 if (authStrategies.indexOf('google') >= 0) { QV('auth-google', true); }
425 if (authStrategies.indexOf('github') >= 0) { QV('auth-github', true); }
427 - if (authStrategies.indexOf('reddit') >= 0) { QV('auth-reddit', true); }
426 if (authStrategies.indexOf('azure') >= 0) { QV('auth-azure', true); }
427 if (authStrategies.indexOf('oidc') >= 0) { QV('auth-oidc', true); }
428 if (authStrategies.indexOf('oidc-azure') >= 0) { QV('auth-oidc-azure', true); }
views/login2.handlebars
-2
@@ -104,7 +104,6 @@
104 <a id="auth-twitter" href="auth-twitter" style="display:none"><img src="images/login/twitter32.png" srcset="images/login/twitter64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Twitter" /></a>
105 <a id="auth-google" href="auth-google" style="display:none"><img src="images/login/google32.png" srcset="images/login/google64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Google" /></a>
106 <a id="auth-github" href="auth-github" style="display:none"><img src="images/login/github32.png" srcset="images/login/github64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using GitHub" /></a>
107 - <a id="auth-reddit" href="auth-reddit" style="display:none"><img src="images/login/reddit32.png" srcset="images/login/reddit64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Reddit" /></a>
107 <a id="auth-azure" href="auth-azure" style="display:none"><img src="images/login/azure32.png" srcset="images/login/azure64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using Azure" /></a>
108 <a id="auth-oidc" href="auth-oidc" style="display:none"><img src="images/login/oidc32.png" srcset="images/login/oidc64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in using OpenID Connect" /></a>
109 <a id="auth-oidc-azure" href="auth-oidc" style="display:none"><img src="images/login/azure32.png" srcset="images/login/azure64.png 2x" loading="lazy" width="32" height="32" style="margin-left:3px;margin-right:3px;border-radius:3px;box-shadow:2px 2px 5px black;cursor:pointer" title="Sign-in with Azure using OpenID Connect" /></a>
@@ -508,7 +507,6 @@
507 if (authStrategies.indexOf('twitter') >= 0) { QV('auth-twitter', true); }
508 if (authStrategies.indexOf('google') >= 0) { QV('auth-google', true); }
509 if (authStrategies.indexOf('github') >= 0) { QV('auth-github', true); }
511 - if (authStrategies.indexOf('reddit') >= 0) { QV('auth-reddit', true); }
510 if (authStrategies.indexOf('azure') >= 0) { QV('auth-azure', true); }
511 if (authStrategies.indexOf('oidc') >= 0) { QV('auth-oidc', true); }
512 if (authStrategies.indexOf('oidc-azure') >= 0) { QV('auth-oidc-azure', true); }
webserver.js
+1 -45
@@ -3308,7 +3308,6 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
3308 if (typeof domain.authstrategies.twitter == 'object') { authStrategies.push('twitter'); }
3309 if (typeof domain.authstrategies.google == 'object') { authStrategies.push('google'); }
3310 if (typeof domain.authstrategies.github == 'object') { authStrategies.push('github'); }
3311 - if (typeof domain.authstrategies.reddit == 'object') { authStrategies.push('reddit'); }
3311 if (typeof domain.authstrategies.azure == 'object') { authStrategies.push('azure'); }
3312 if (typeof domain.authstrategies.oidc == 'object') {
3313 if (obj.common.validateObject(domain.authstrategies.oidc.custom) && obj.common.validateString(domain.authstrategies.oidc.custom.preset)) {
@@ -6661,32 +6660,6 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
6660 }, handleStrategyLogin);
6661 }
6662
6664 - // Reddit
6665 - if ((domain.authstrategies.authStrategyFlags & domainAuthStrategyConsts.reddit) != 0) {
6666 - obj.app.get(url + 'auth-reddit', function (req, res, next) {
6667 - var domain = getDomain(req);
6668 - if (domain.passport == null) { next(); return; }
6669 - domain.passport.authenticate('reddit-' + domain.id, { state: obj.parent.encodeCookie({ 'p': 'reddit' }, obj.parent.loginCookieEncryptionKey), duration: 'permanent' })(req, res, next);
6670 - });
6671 - obj.app.get(url + 'auth-reddit-callback', function (req, res, next) {
6672 - var domain = getDomain(req);
6673 - if (domain.passport == null) { next(); return; }
6674 - if ((Object.keys(req.session).length == 0) && (req.query.nmr == null)) {
6675 - // This is an empty session likely due to the 302 redirection, redirect again (this is a bit of a hack).
6676 - var url = req.url;
6677 - if (url.indexOf('?') >= 0) { url += '&nmr=1'; } else { url += '?nmr=1'; } // Add this to the URL to prevent redirect loop.
6678 - res.set('Content-Type', 'text/html');
6679 - res.end('<html><head><meta http-equiv="refresh" content=0;url="' + url + '"></head><body></body></html>');
6680 - } else {
6681 - if (req.query.state != null) {
6682 - var c = obj.parent.decodeCookie(req.query.state, obj.parent.loginCookieEncryptionKey, 10); // 10 minute timeout
6683 - if ((c != null) && (c.p == 'reddit')) { domain.passport.authenticate('reddit-' + domain.id, { failureRedirect: '/' })(req, res, next); return; }
6684 - }
6685 - next();
6686 - }
6687 - }, handleStrategyLogin);
6688 - }
6689 -
6663 // Azure
6664 if ((domain.authstrategies.authStrategyFlags & domainAuthStrategyConsts.azure) != 0) {
6665 obj.app.get(url + 'auth-azure', function (req, res, next) {
@@ -7089,7 +7062,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
7062 twitter: 1,
7063 google: 2,
7064 github: 3,
7092 - reddit: 8,
7065 + reddit: 8, // Deprecated
7066 azure: 16,
7067 oidc: 32,
7068 saml: 64,
@@ -7162,23 +7135,6 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
7135 authStrategyFlags |= domainAuthStrategyConsts.github;
7136 }
7137
7165 - // Reddit
7166 - if ((typeof domain.authstrategies.reddit == 'object') && (typeof domain.authstrategies.reddit.clientid == 'string') && (typeof domain.authstrategies.reddit.clientsecret == 'string')) {
7167 - const RedditStrategy = require('passport-reddit');
7168 - let options = { clientID: domain.authstrategies.reddit.clientid, clientSecret: domain.authstrategies.reddit.clientsecret };
7169 - if (typeof domain.authstrategies.reddit.callbackurl == 'string') { options.callbackURL = domain.authstrategies.reddit.callbackurl; } else { options.callbackURL = url + 'auth-reddit-callback'; }
7170 - parent.authLog('setupDomainAuthStrategy', 'Adding Reddit SSO with options: ' + JSON.stringify(options));
7171 - passport.use('reddit-' + domain.id, new RedditStrategy.Strategy(options,
7172 - function (token, tokenSecret, profile, cb) {
7173 - parent.authLog('setupDomainAuthStrategy', 'Reddit profile: ' + JSON.stringify(profile));
7174 - var user = { sid: '~reddit:' + profile.id, name: profile.name, strategy: 'reddit' };
7175 - if ((typeof profile.emails == 'object') && (profile.emails[0] != null) && (typeof profile.emails[0].value == 'string')) { user.email = profile.emails[0].value; }
7176 - return cb(null, user);
7177 - }
7178 - ));
7179 - authStrategyFlags |= domainAuthStrategyConsts.reddit;
7180 - }
7181 -
7138 // Azure
7139 if ((typeof domain.authstrategies.azure == 'object') && (typeof domain.authstrategies.azure.clientid == 'string') && (typeof domain.authstrategies.azure.clientsecret == 'string')) {
7140 const AzureOAuth2Strategy = require('passport-azure-oauth2');