fix(xo-server-auth-ldap): mark userIdAttribute as required

It can no longer be ommited since 99605bf18
This commit is contained in:
Julien Fontanet 2023-08-03 09:56:33 +02:00
parent 035679800a
commit 2d25413b8d
2 changed files with 15 additions and 17 deletions

View File

@ -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 @@
<!--packages-start-->
- xo-server-auth-ldap patch
<!--packages-end-->

View File

@ -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}`)
}
}