settings: move externaldap setting
This commit is contained in:
@@ -12,7 +12,6 @@ const assert = require('assert'),
|
||||
backups = require('../backups.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
docker = require('../docker.js'),
|
||||
externalLdap = require('../externalldap.js'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
safe = require('safetydance'),
|
||||
@@ -110,31 +109,6 @@ async function setBackupConfig(req, res, next) {
|
||||
next(new HttpSuccess(200, {}));
|
||||
}
|
||||
|
||||
async function getExternalLdapConfig(req, res, next) {
|
||||
const [error, config] = await safe(settings.getExternalLdapConfig());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, externalLdap.removePrivateFields(config)));
|
||||
}
|
||||
|
||||
async function setExternalLdapConfig(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if (!req.body.provider || typeof req.body.provider !== 'string') return next(new HttpError(400, 'provider must be a string'));
|
||||
if ('url' in req.body && typeof req.body.url !== 'string') return next(new HttpError(400, 'url must be a string'));
|
||||
if ('baseDn' in req.body && typeof req.body.baseDn !== 'string') return next(new HttpError(400, 'baseDn must be a string'));
|
||||
if ('usernameField' in req.body && typeof req.body.usernameField !== 'string') return next(new HttpError(400, 'usernameField must be a string'));
|
||||
if ('filter' in req.body && typeof req.body.filter !== 'string') return next(new HttpError(400, 'filter must be a string'));
|
||||
if ('groupBaseDn' in req.body && typeof req.body.groupBaseDn !== 'string') return next(new HttpError(400, 'groupBaseDn must be a string'));
|
||||
if ('bindDn' in req.body && typeof req.body.bindDn !== 'string') return next(new HttpError(400, 'bindDn must be a non empty string'));
|
||||
if ('bindPassword' in req.body && typeof req.body.bindPassword !== 'string') return next(new HttpError(400, 'bindPassword must be a string'));
|
||||
|
||||
const [error] = await safe(settings.setExternalLdapConfig(req.body));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
}
|
||||
|
||||
async function getDirectoryServerConfig(req, res, next) {
|
||||
const [error, config] = await safe(settings.getDirectoryServerConfig());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
@@ -278,7 +252,6 @@ function get(req, res, next) {
|
||||
case settings.BACKUP_POLICY_KEY: return getBackupPolicy(req, res, next);
|
||||
case settings.IPV6_CONFIG_KEY: return getIPv6Config(req, res, next);
|
||||
case settings.BACKUP_CONFIG_KEY: return getBackupConfig(req, res, next);
|
||||
case settings.EXTERNAL_LDAP_KEY: return getExternalLdapConfig(req, res, next);
|
||||
case settings.DIRECTORY_SERVER_KEY: return getDirectoryServerConfig(req, res, next);
|
||||
case settings.REGISTRY_CONFIG_KEY: return getRegistryConfig(req, res, next);
|
||||
case settings.SYSINFO_CONFIG_KEY: return getSysinfoConfig(req, res, next);
|
||||
@@ -299,7 +272,6 @@ function set(req, res, next) {
|
||||
switch (req.params.setting) {
|
||||
case settings.BACKUP_POLICY_KEY: return setBackupPolicy(req, res, next);
|
||||
case settings.IPV6_CONFIG_KEY: return setIPv6Config(req, res, next);
|
||||
case settings.EXTERNAL_LDAP_KEY: return setExternalLdapConfig(req, res, next);
|
||||
case settings.DIRECTORY_SERVER_KEY: return setDirectoryServerConfig(req, res, next);
|
||||
case settings.REGISTRY_CONFIG_KEY: return setRegistryConfig(req, res, next);
|
||||
case settings.SYSINFO_CONFIG_KEY: return setSysinfoConfig(req, res, next);
|
||||
|
||||
Reference in New Issue
Block a user