rename user directory to directory server
This commit is contained in:
@@ -34,8 +34,8 @@ exports = module.exports = {
|
||||
getExternalLdapConfig,
|
||||
setExternalLdapConfig,
|
||||
|
||||
getUserDirectoryConfig,
|
||||
setUserDirectoryConfig,
|
||||
getDirectoryServerConfig,
|
||||
setDirectoryServerConfig,
|
||||
|
||||
getRegistryConfig,
|
||||
setRegistryConfig,
|
||||
@@ -100,7 +100,7 @@ exports = module.exports = {
|
||||
BACKUP_CONFIG_KEY: 'backup_config',
|
||||
SERVICES_CONFIG_KEY: 'services_config',
|
||||
EXTERNAL_LDAP_KEY: 'external_ldap_config',
|
||||
USER_DIRECTORY_KEY: 'user_directory_config',
|
||||
DIRECTORY_SERVER_KEY: 'user_directory_config',
|
||||
REGISTRY_CONFIG_KEY: 'registry_config',
|
||||
SYSINFO_CONFIG_KEY: 'sysinfo_config', // misnomer: ipv4 config
|
||||
APPSTORE_LISTING_CONFIG_KEY: 'appstore_listing_config',
|
||||
@@ -148,6 +148,7 @@ const assert = require('assert'),
|
||||
CronJob = require('cron').CronJob,
|
||||
database = require('./database.js'),
|
||||
debug = require('debug')('box:settings'),
|
||||
directoryServer = require('./directoryserver.js'),
|
||||
docker = require('./docker.js'),
|
||||
externalLdap = require('./externalldap.js'),
|
||||
moment = require('moment-timezone'),
|
||||
@@ -157,7 +158,6 @@ const assert = require('assert'),
|
||||
sysinfo = require('./sysinfo.js'),
|
||||
tokens = require('./tokens.js'),
|
||||
translation = require('./translation.js'),
|
||||
userdirectory = require('./userdirectory.js'),
|
||||
users = require('./users.js'),
|
||||
_ = require('underscore');
|
||||
|
||||
@@ -194,7 +194,7 @@ const gDefaults = (function () {
|
||||
provider: 'noop',
|
||||
autoCreate: false
|
||||
};
|
||||
result[exports.USER_DIRECTORY_KEY] = {
|
||||
result[exports.DIRECTORY_SERVER_KEY] = {
|
||||
enabled: false,
|
||||
secret: '',
|
||||
allowlist: '' // empty means allow all
|
||||
@@ -528,29 +528,29 @@ async function setExternalLdapConfig(externalLdapConfig) {
|
||||
notifyChange(exports.EXTERNAL_LDAP_KEY, externalLdapConfig);
|
||||
}
|
||||
|
||||
async function getUserDirectoryConfig() {
|
||||
const value = await get(exports.USER_DIRECTORY_KEY);
|
||||
if (value === null) return gDefaults[exports.USER_DIRECTORY_KEY];
|
||||
async function getDirectoryServerConfig() {
|
||||
const value = await get(exports.DIRECTORY_SERVER_KEY);
|
||||
if (value === null) return gDefaults[exports.DIRECTORY_SERVER_KEY];
|
||||
return JSON.parse(value);
|
||||
}
|
||||
|
||||
async function setUserDirectoryConfig(userDirectoryConfig) {
|
||||
assert.strictEqual(typeof userDirectoryConfig, 'object');
|
||||
async function setDirectoryServerConfig(directoryServerConfig) {
|
||||
assert.strictEqual(typeof directoryServerConfig, 'object');
|
||||
|
||||
if (isDemo()) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode');
|
||||
|
||||
const config = {
|
||||
enabled: userDirectoryConfig.enabled,
|
||||
secret: userDirectoryConfig.secret,
|
||||
enabled: directoryServerConfig.enabled,
|
||||
secret: directoryServerConfig.secret,
|
||||
// if list is empty, we allow all IPs
|
||||
allowlist: userDirectoryConfig.allowlist || ''
|
||||
allowlist: directoryServerConfig.allowlist || ''
|
||||
};
|
||||
|
||||
await userdirectory.validateConfig(config);
|
||||
await set(exports.USER_DIRECTORY_KEY, JSON.stringify(config));
|
||||
await userdirectory.applyConfig(config);
|
||||
await directoryServer.validateConfig(config);
|
||||
await set(exports.DIRECTORY_SERVER_KEY, JSON.stringify(config));
|
||||
await directoryServer.applyConfig(config);
|
||||
|
||||
notifyChange(exports.USER_DIRECTORY_KEY, config);
|
||||
notifyChange(exports.DIRECTORY_SERVER_KEY, config);
|
||||
}
|
||||
|
||||
async function getRegistryConfig() {
|
||||
|
||||
Reference in New Issue
Block a user