diff --git a/dashboard/src/js/client.js b/dashboard/src/js/client.js index 048acddb8..ab09372d3 100644 --- a/dashboard/src/js/client.js +++ b/dashboard/src/js/client.js @@ -3563,6 +3563,8 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout var ACTION_DASHBOARD_DOMAIN_UPDATE = 'dashboard.domain.update'; + var ACTION_DIRECTORY_SERVER_CONFIGURE = 'directoryserver.configure'; + var ACTION_DOMAIN_ADD = 'domain.add'; var ACTION_DOMAIN_UPDATE = 'domain.update'; var ACTION_DOMAIN_REMOVE = 'domain.remove'; @@ -3817,6 +3819,13 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout case ACTION_DASHBOARD_DOMAIN_UPDATE: return 'Dashboard domain set to ' + data.fqdn || (data.subdomain + '.' + data.domain); + case ACTION_DIRECTORY_SERVER_CONFIGURE: + if (data.fromEnabled !== data.toEnabled) { + return 'Directory server was ' + (data.toEnabled ? 'enabled' : 'disabled'); + } else { + return 'Directory server configuration was changed'; + } + case ACTION_DOMAIN_ADD: return 'Domain ' + data.domain + ' with ' + data.provider + ' provider was added'; diff --git a/dashboard/src/views/eventlog.js b/dashboard/src/views/eventlog.js index 2ec3606e6..c7bd7f98d 100644 --- a/dashboard/src/views/eventlog.js +++ b/dashboard/src/views/eventlog.js @@ -46,6 +46,7 @@ angular.module('Application').controller('EventLogController', ['$scope', '$loca { name: 'cloudron.update', value: 'cloudron.update' }, { name: 'cloudron.update.finish', value: 'cloudron.update.finish' }, { name: 'dashboard.domain.update', value: 'dashboard.domain.update' }, + { name: 'directoryserver.configure', value: 'directoryserver.configure' }, { name: 'dyndns.update', value: 'dyndns.update' }, { name: 'domain.add', value: 'domain.add' }, { name: 'domain.update', value: 'domain.update' }, diff --git a/src/directoryserver.js b/src/directoryserver.js index 525c9e805..67fa7421d 100644 --- a/src/directoryserver.js +++ b/src/directoryserver.js @@ -86,11 +86,14 @@ async function applyConfig(config) { if (!gServer) await start(); } -async function setConfig(directoryServerConfig) { +async function setConfig(directoryServerConfig, auditSource) { assert.strictEqual(typeof directoryServerConfig, 'object'); + assert(auditSource && typeof auditSource === 'object'); if (constants.DEMO) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode'); + const oldConfig = await getConfig(); + const config = { enabled: directoryServerConfig.enabled, secret: directoryServerConfig.secret, @@ -101,6 +104,8 @@ async function setConfig(directoryServerConfig) { await validateConfig(config); await settings.setJson(settings.DIRECTORY_SERVER_KEY, config); await applyConfig(config); + + await eventlog.add(eventlog.ACTION_DIRECTORY_SERVER_CONFIGURE, auditSource, { fromEnabled: oldConfig.enabled, toEnabled: config.enabled }); } // helper function to deal with pagination diff --git a/src/eventlog.js b/src/eventlog.js index b23e73eef..33760f357 100644 --- a/src/eventlog.js +++ b/src/eventlog.js @@ -41,6 +41,8 @@ exports = module.exports = { ACTION_DASHBOARD_DOMAIN_UPDATE: 'dashboard.domain.update', + ACTION_DIRECTORY_SERVER_CONFIGURE: 'directoryserver.configure', + ACTION_DOMAIN_ADD: 'domain.add', ACTION_DOMAIN_UPDATE: 'domain.update', ACTION_DOMAIN_REMOVE: 'domain.remove', diff --git a/src/routes/directoryserver.js b/src/routes/directoryserver.js index 868b97131..d13a8ddf5 100644 --- a/src/routes/directoryserver.js +++ b/src/routes/directoryserver.js @@ -6,6 +6,7 @@ exports = module.exports = { }; const assert = require('assert'), + AuditSource = require('../auditsource.js'), BoxError = require('../boxerror.js'), directoryServer = require('../directoryserver.js'), HttpError = require('connect-lastmile').HttpError, @@ -28,7 +29,7 @@ async function setConfig(req, res, next) { if ('secret' in req.body && typeof req.body.secret !== 'string') return next(new HttpError(400, 'secret must be a string')); if ('allowlist' in req.body && typeof req.body.allowlist !== 'string') return next(new HttpError(400, 'allowlist must be a string')); - const [error] = await safe(directoryServer.setConfig(req.body)); + const [error] = await safe(directoryServer.setConfig(req.body, AuditSource.fromRequest(req))); if (error) return next(BoxError.toHttpError(error)); next(new HttpSuccess(200, {}));