settings: move externaldap setting
This commit is contained in:
@@ -19,9 +19,6 @@ exports = module.exports = {
|
||||
getServicesConfig,
|
||||
setServicesConfig,
|
||||
|
||||
getExternalLdapConfig,
|
||||
setExternalLdapConfig,
|
||||
|
||||
getDirectoryServerConfig,
|
||||
setDirectoryServerConfig,
|
||||
|
||||
@@ -126,7 +123,6 @@ const assert = require('assert'),
|
||||
debug = require('debug')('box:settings'),
|
||||
directoryServer = require('./directoryserver.js'),
|
||||
docker = require('./docker.js'),
|
||||
externalLdap = require('./externalldap.js'),
|
||||
moment = require('moment-timezone'),
|
||||
mounts = require('./mounts.js'),
|
||||
paths = require('./paths.js'),
|
||||
@@ -160,10 +156,6 @@ const gDefaults = (function () {
|
||||
schedule: '00 00 23 * * *' // every day at 11pm
|
||||
};
|
||||
result[exports.SERVICES_CONFIG_KEY] = {};
|
||||
result[exports.EXTERNAL_LDAP_KEY] = {
|
||||
provider: 'noop',
|
||||
autoCreate: false
|
||||
};
|
||||
result[exports.DIRECTORY_SERVER_KEY] = {
|
||||
enabled: false,
|
||||
secret: '',
|
||||
@@ -376,32 +368,6 @@ async function setServicesConfig(platformConfig) {
|
||||
notifyChange(exports.SERVICES_CONFIG_KEY, platformConfig);
|
||||
}
|
||||
|
||||
async function getExternalLdapConfig() {
|
||||
const value = await get(exports.EXTERNAL_LDAP_KEY);
|
||||
if (value === null) return gDefaults[exports.EXTERNAL_LDAP_KEY];
|
||||
|
||||
const config = JSON.parse(value);
|
||||
if (!config.autoCreate) config.autoCreate = false; // ensure new keys
|
||||
return config;
|
||||
}
|
||||
|
||||
async function setExternalLdapConfig(externalLdapConfig) {
|
||||
assert.strictEqual(typeof externalLdapConfig, 'object');
|
||||
|
||||
if (isDemo()) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode');
|
||||
|
||||
const currentConfig = await getExternalLdapConfig();
|
||||
|
||||
externalLdap.injectPrivateFields(externalLdapConfig, currentConfig);
|
||||
|
||||
const error = await externalLdap.testConfig(externalLdapConfig);
|
||||
if (error) throw error;
|
||||
|
||||
await set(exports.EXTERNAL_LDAP_KEY, JSON.stringify(externalLdapConfig));
|
||||
|
||||
notifyChange(exports.EXTERNAL_LDAP_KEY, externalLdapConfig);
|
||||
}
|
||||
|
||||
async function getDirectoryServerConfig() {
|
||||
const value = await get(exports.DIRECTORY_SERVER_KEY);
|
||||
if (value === null) return gDefaults[exports.DIRECTORY_SERVER_KEY];
|
||||
@@ -534,7 +500,7 @@ async function list() {
|
||||
|
||||
// convert JSON objects
|
||||
[exports.BACKUP_POLICY_KEY, exports.BACKUP_CONFIG_KEY, exports.IPV6_CONFIG_KEY, exports.PROFILE_CONFIG_KEY, exports.SERVICES_CONFIG_KEY,
|
||||
exports.EXTERNAL_LDAP_KEY, exports.REGISTRY_CONFIG_KEY, exports.SYSINFO_CONFIG_KEY, exports.REVERSE_PROXY_CONFIG_KEY ].forEach(function (key) {
|
||||
exports.REGISTRY_CONFIG_KEY, exports.SYSINFO_CONFIG_KEY, exports.REVERSE_PROXY_CONFIG_KEY ].forEach(function (key) {
|
||||
result[key] = typeof result[key] === 'object' ? result[key] : safe.JSON.parse(result[key]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user