0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Added a feature flag to the oauth login feature

issue https://github.com/TryGhost/Team/issues/614

- The feature flag was called `oauthLogin` instead of simply `oauth` to avoid clashes in the frontend `feature` service as it is merging the config and labs properties.
This commit is contained in:
Thibaut Patel 2021-07-20 23:16:49 +02:00
parent 1eef1e9781
commit 489e470d7b
3 changed files with 12 additions and 6 deletions

View file

@ -2,6 +2,7 @@ const ghostVersion = require('@tryghost/version');
const settingsCache = require('../../../shared/settings-cache'); const settingsCache = require('../../../shared/settings-cache');
const config = require('../../../shared/config'); const config = require('../../../shared/config');
const urlUtils = require('../../../shared/url-utils'); const urlUtils = require('../../../shared/url-utils');
const labs = require('../../../shared/labs');
module.exports = function getSiteProperties() { module.exports = function getSiteProperties() {
const siteProperties = { const siteProperties = {
@ -14,7 +15,7 @@ module.exports = function getSiteProperties() {
version: ghostVersion.safe version: ghostVersion.safe
}; };
if (settingsCache.get('oauth_client_id') && settingsCache.get('oauth_client_secret')) { if (labs.isSet('oauthLogin') && settingsCache.get('oauth_client_id') && settingsCache.get('oauth_client_secret')) {
// Only set the oauth flag if oauth is enabled to avoid API changes // Only set the oauth flag if oauth is enabled to avoid API changes
siteProperties.oauth = true; siteProperties.oauth = true;
} }

View file

@ -5,10 +5,10 @@ const GoogleStrategy = require('passport-google-oauth20').Strategy;
const express = require('../../../shared/express'); const express = require('../../../shared/express');
const urlUtils = require('../../../shared/url-utils'); const urlUtils = require('../../../shared/url-utils');
const shared = require('../shared'); const shared = require('../shared');
const config = require('../../../shared/config');
const settingsCache = require('../../../shared/settings-cache'); const settingsCache = require('../../../shared/settings-cache');
const models = require('../../models'); const models = require('../../models');
const auth = require('../../services/auth'); const auth = require('../../services/auth');
const labs = require('../../../shared/labs');
function randomPassword() { function randomPassword() {
return require('crypto').randomBytes(128).toString('hex'); return require('crypto').randomBytes(128).toString('hex');
@ -17,10 +17,14 @@ function randomPassword() {
module.exports = function setupOAuthApp() { module.exports = function setupOAuthApp() {
debug('OAuth App setup start'); debug('OAuth App setup start');
const oauthApp = express('oauth'); const oauthApp = express('oauth');
if (!config.get('enableDeveloperExperiments')) {
debug('OAuth App setup skipped'); function labsMiddleware(req, res, next) {
return oauthApp; if (labs.isSet('oauthLogin')) {
return next();
} }
res.sendStatus(404);
}
oauthApp.use(labsMiddleware);
// send 503 json response in case of maintenance // send 503 json response in case of maintenance
oauthApp.use(shared.middlewares.maintenance); oauthApp.use(shared.middlewares.maintenance);

View file

@ -26,7 +26,8 @@ const ALPHA_FEATURES = [
'multipleProducts', 'multipleProducts',
'savedIndicator', 'savedIndicator',
'featureImgDragDrop', 'featureImgDragDrop',
'checkEmailList' 'checkEmailList',
'oauthLogin'
]; ];
module.exports.WRITABLE_KEYS_ALLOWLIST = [...BETA_FEATURES, ...ALPHA_FEATURES]; module.exports.WRITABLE_KEYS_ALLOWLIST = [...BETA_FEATURES, ...ALPHA_FEATURES];