chore: remove unused LDAP mail attribute

This commit is contained in:
RatCornu 2025-08-10 12:50:19 +02:00 committed by Ellis Git
commit fb7e739b72
3 changed files with 20 additions and 32 deletions

View file

@ -1797,7 +1797,7 @@
# #
# example: "ou=users,dc=example,dc=org" # example: "ou=users,dc=example,dc=org"
# #
#base_dn = false #base_dn =
# Bind DN if anonymous search is not enabled. # Bind DN if anonymous search is not enabled.
# #
@ -1810,7 +1810,7 @@
# example: "cn=ldap-reader,dc=example,dc=org" or # example: "cn=ldap-reader,dc=example,dc=org" or
# "cn={username},ou=users,dc=example,dc=org" # "cn={username},ou=users,dc=example,dc=org"
# #
#bind_dn = false #bind_dn =
# Path to a file on the system that contains the password for the # Path to a file on the system that contains the password for the
# `bind_dn`. # `bind_dn`.
@ -1834,13 +1834,7 @@
# #
#uid_attribute = "uid" #uid_attribute = "uid"
# Attribute containing the mail of the user. # Attribute containing the display name of the user.
#
# example: "mail"
#
#mail_attribute = "mail"
# Attribute containing the distinguished name of the user.
# #
# example: "givenName" or "sn" # example: "givenName" or "sn"
# #
@ -1852,9 +1846,9 @@
# #
# example: "ou=admins,dc=example,dc=org" # example: "ou=admins,dc=example,dc=org"
# #
#admin_base_dn = false #admin_base_dn =
# The LDAP search filter to find administrative users for conduwuit. # The LDAP search filter to find administrative users for continuwuity.
# #
# If left blank, administrative state must be configured manually for each # If left blank, administrative state must be configured manually for each
# user. # user.
@ -1864,4 +1858,4 @@
# #
# example: "(objectClass=conduwuitAdmin)" or "(uid={username})" # example: "(objectClass=conduwuitAdmin)" or "(uid={username})"
# #
#admin_filter = false #admin_filter =

View file

@ -156,9 +156,9 @@ pub(super) async fn ldap_login(
pub(crate) async fn handle_login( pub(crate) async fn handle_login(
services: &Services, services: &Services,
body: &Ruma<login::v3::Request>, body: &Ruma<login::v3::Request>,
identifier: &Option<uiaa::UserIdentifier>, identifier: Option<&uiaa::UserIdentifier>,
password: &str, password: &str,
user: &Option<String>, user: Option<&String>,
) -> Result<OwnedUserId> { ) -> Result<OwnedUserId> {
debug!("Got password login type"); debug!("Got password login type");
let user_id = let user_id =
@ -185,7 +185,7 @@ pub(crate) async fn handle_login(
} }
if cfg!(feature = "ldap") && services.config.ldap.enable { if cfg!(feature = "ldap") && services.config.ldap.enable {
ldap_login(services, &user_id, &lowercased_user_id, password).await Box::pin(ldap_login(services, &user_id, &lowercased_user_id, password)).await
} else { } else {
password_login(services, &user_id, &lowercased_user_id, password).await password_login(services, &user_id, &lowercased_user_id, password).await
} }
@ -222,7 +222,7 @@ pub(crate) async fn login_route(
password, password,
user, user,
.. ..
}) => handle_login(&services, &body, identifier, password, user).await?, }) => handle_login(&services, &body, identifier.as_ref(), password, user.as_ref()).await?,
| login::v3::LoginInfo::Token(login::v3::Token { token }) => { | login::v3::LoginInfo::Token(login::v3::Token { token }) => {
debug!("Got token login type"); debug!("Got token login type");
if !services.server.config.login_via_existing_session { if !services.server.config.login_via_existing_session {

View file

@ -2063,7 +2063,7 @@ pub struct LdapConfig {
/// Root of the searches. /// Root of the searches.
/// ///
/// example: "ou=users,dc=example,dc=org" /// example: "ou=users,dc=example,dc=org"
#[serde(default)] #[serde(default = "empty_string_fn")]
pub base_dn: String, pub base_dn: String,
/// Bind DN if anonymous search is not enabled. /// Bind DN if anonymous search is not enabled.
@ -2076,7 +2076,7 @@ pub struct LdapConfig {
/// ///
/// example: "cn=ldap-reader,dc=example,dc=org" or /// example: "cn=ldap-reader,dc=example,dc=org" or
/// "cn={username},ou=users,dc=example,dc=org" /// "cn={username},ou=users,dc=example,dc=org"
#[serde(default)] #[serde(default = "some_empty_string_fn")]
pub bind_dn: Option<String>, pub bind_dn: Option<String>,
/// Path to a file on the system that contains the password for the /// Path to a file on the system that contains the password for the
@ -2105,15 +2105,7 @@ pub struct LdapConfig {
#[serde(default = "default_ldap_uid_attribute")] #[serde(default = "default_ldap_uid_attribute")]
pub uid_attribute: String, pub uid_attribute: String,
/// Attribute containing the mail of the user. /// Attribute containing the display name of the user.
///
/// example: "mail"
///
/// default: "mail"
#[serde(default = "default_ldap_mail_attribute")]
pub mail_attribute: String,
/// Attribute containing the distinguished name of the user.
/// ///
/// example: "givenName" or "sn" /// example: "givenName" or "sn"
/// ///
@ -2126,10 +2118,10 @@ pub struct LdapConfig {
/// Defaults to `base_dn` if empty. /// Defaults to `base_dn` if empty.
/// ///
/// example: "ou=admins,dc=example,dc=org" /// example: "ou=admins,dc=example,dc=org"
#[serde(default)] #[serde(default = "empty_string_fn")]
pub admin_base_dn: String, pub admin_base_dn: String,
/// The LDAP search filter to find administrative users for conduwuit. /// The LDAP search filter to find administrative users for continuwuity.
/// ///
/// If left blank, administrative state must be configured manually for each /// If left blank, administrative state must be configured manually for each
/// user. /// user.
@ -2138,7 +2130,7 @@ pub struct LdapConfig {
/// entered username for more complex filters. /// entered username for more complex filters.
/// ///
/// example: "(objectClass=conduwuitAdmin)" or "(uid={username})" /// example: "(objectClass=conduwuitAdmin)" or "(uid={username})"
#[serde(default)] #[serde(default = "empty_string_fn")]
pub admin_filter: String, pub admin_filter: String,
} }
@ -2240,6 +2232,10 @@ impl Config {
fn true_fn() -> bool { true } fn true_fn() -> bool { true }
fn empty_string_fn() -> String { String::new() }
fn some_empty_string_fn() -> Option<String> { Some(String::new()) }
fn default_address() -> ListeningAddr { fn default_address() -> ListeningAddr {
ListeningAddr { ListeningAddr {
addrs: Right(vec![Ipv4Addr::LOCALHOST.into(), Ipv6Addr::LOCALHOST.into()]), addrs: Right(vec![Ipv4Addr::LOCALHOST.into(), Ipv6Addr::LOCALHOST.into()]),
@ -2536,6 +2532,4 @@ fn default_ldap_search_filter() -> String { "(objectClass=*)".to_owned() }
fn default_ldap_uid_attribute() -> String { String::from("uid") } fn default_ldap_uid_attribute() -> String { String::from("uid") }
fn default_ldap_mail_attribute() -> String { String::from("mail") }
fn default_ldap_name_attribute() -> String { String::from("givenName") } fn default_ldap_name_attribute() -> String { String::from("givenName") }