mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
* Allow LDAP login via username This patch adds the option to login via username instead of using an email address since the latter may not be unique or may change. For example, our organization has two main domains and users have a log and a short form of their mail address. This makes it hard for users to identify what their primary email address is and causes a lot of confusion. Using their username instead makes it much easier. Using a username will also make it easier in the future to not need a separate bind user to get user attributes. So, this is also a bit of prep work for that. * Update config.js * feat: Enable LDAP login via username This commit enables the option to login via username instead of using an email address for LDAP authentication. This change is necessary because email addresses may not be unique or may change, causing confusion for users. By using usernames, it becomes easier for users to identify their primary email address. Additionally, this change prepares for future improvements by eliminating the need for a separate bind user to retrieve user attributes. Co-authored-by: Danny Avila <danny@librechat.ai> * chore: jsdocs * chore: import order * ci: add ldap config tests --------- Co-authored-by: Lars Kiesow <lkiesow@uos.de>
22 lines
511 B
JavaScript
22 lines
511 B
JavaScript
const { isEnabled } = require('~/server/utils');
|
|
|
|
/** @returns {TStartupConfig['ldap'] | undefined} */
|
|
const getLdapConfig = () => {
|
|
const ldapLoginEnabled = !!process.env.LDAP_URL && !!process.env.LDAP_USER_SEARCH_BASE;
|
|
|
|
const ldap = {
|
|
enabled: ldapLoginEnabled,
|
|
};
|
|
const ldapLoginUsesUsername = isEnabled(process.env.LDAP_LOGIN_USES_USERNAME);
|
|
if (!ldapLoginEnabled) {
|
|
return ldap;
|
|
}
|
|
|
|
if (ldapLoginUsesUsername) {
|
|
ldap.username = true;
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
getLdapConfig,
|
|
};
|