From 2d25413b8dff6d7842b0c1a214aa3ba18507ce5e Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Thu, 3 Aug 2023 09:56:33 +0200 Subject: [PATCH] fix(xo-server-auth-ldap): mark userIdAttribute as required It can no longer be ommited since 99605bf18 --- CHANGELOG.unreleased.md | 4 ++++ packages/xo-server-auth-ldap/src/index.js | 28 +++++++++-------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 77ab5de5a..19463835d 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -11,6 +11,8 @@ > Users must be able to say: “I had this issue, happy to know it's fixed” +- [LDAP] Mark the _Id attribute_ setting as required + ### Packages to release > When modifying a package, add it here with its release type. @@ -27,4 +29,6 @@ +- xo-server-auth-ldap patch + diff --git a/packages/xo-server-auth-ldap/src/index.js b/packages/xo-server-auth-ldap/src/index.js index 26adef3f9..c029e2818 100644 --- a/packages/xo-server-auth-ldap/src/index.js +++ b/packages/xo-server-auth-ldap/src/index.js @@ -159,7 +159,7 @@ Or something like this if you also want to filter by group: required: ['base', 'filter', 'idAttribute', 'displayNameAttribute', 'membersMapping'], }, }, - required: ['uri', 'base'], + required: ['uri', 'base', 'userIdAttribute'], } export const testSchema = { @@ -290,23 +290,17 @@ class AuthLdap { return } - let user - if (this._userIdAttribute === undefined) { - // Support legacy config - user = await this._xo.registerUser(undefined, username) - } else { - const ldapId = entry[this._userIdAttribute] - user = await this._xo.registerUser2('ldap', { - user: { id: ldapId, name: username }, - }) + const ldapId = entry[this._userIdAttribute] + const user = await this._xo.registerUser2('ldap', { + user: { id: ldapId, name: username }, + }) - const groupsConfig = this._groupsConfig - if (groupsConfig !== undefined) { - try { - await this._synchronizeGroups(user, entry[groupsConfig.membersMapping.userAttribute]) - } catch (error) { - logger.error(`failed to synchronize groups: ${error.message}`) - } + const groupsConfig = this._groupsConfig + if (groupsConfig !== undefined) { + try { + await this._synchronizeGroups(user, entry[groupsConfig.membersMapping.userAttribute]) + } catch (error) { + logger.error(`failed to synchronize groups: ${error.message}`) } }