externalldap: add eventlog

This commit is contained in:
Girish Ramakrishnan
2024-01-13 13:02:43 +01:00
parent 4f9e43859c
commit 4136272382
7 changed files with 42 additions and 24 deletions
+5 -1
View File
@@ -19,6 +19,7 @@ const assert = require('assert'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
debug = require('debug')('box:externalldap'),
eventlog = require('./eventlog.js'),
groups = require('./groups.js'),
ldap = require('ldapjs'),
once = require('./once.js'),
@@ -68,8 +69,9 @@ async function getConfig() {
return config;
}
async function setConfig(newConfig) {
async function setConfig(newConfig, auditSource) {
assert.strictEqual(typeof newConfig, 'object');
assert(auditSource && typeof auditSource === 'object');
if (constants.DEMO) throw new BoxError(BoxError.BAD_FIELD, 'Not allowed in demo mode');
@@ -83,6 +85,8 @@ async function setConfig(newConfig) {
await settings.setJson(settings.EXTERNAL_LDAP_KEY, newConfig);
if (newConfig.provider === 'noop') await users.resetSource(); // otherwise, the owner could be 'ldap' source and lock themselves out
await eventlog.add(eventlog.ACTION_EXTERNAL_LDAP_CONFIGURE, auditSource, { oldConfig: removePrivateFields(currentConfig), config: removePrivateFields(newConfig) });
}
// performs service bind if required