From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id E7FD899AE for ; Mon, 26 Jun 2023 11:39:58 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CAB2425D95 for ; Mon, 26 Jun 2023 11:39:28 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 26 Jun 2023 11:39:28 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id CEEB943B32 for ; Mon, 26 Jun 2023 11:39:27 +0200 (CEST) From: Stefan Sterz To: pbs-devel@lists.proxmox.com Date: Mon, 26 Jun 2023 11:39:13 +0200 Message-Id: <20230626093916.701659-2-s.sterz@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230626093916.701659-1-s.sterz@proxmox.com> References: <20230626093916.701659-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.095 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH proxmox 1/4] ldap: remove support for unauthenticated binds X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jun 2023 09:39:58 -0000 by using the default empty string if no password was provided, unauthenticated binds were possible. to bring pbs in-line with pve, switch to throwing an error in this case instead. however, this will break any pre-existing setup that relied on this behavior. Signed-off-by: Stefan Sterz --- proxmox-ldap/src/lib.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/proxmox-ldap/src/lib.rs b/proxmox-ldap/src/lib.rs index 7c735b8..cdc4c9d 100644 --- a/proxmox-ldap/src/lib.rs +++ b/proxmox-ldap/src/lib.rs @@ -6,7 +6,7 @@ use std::{ time::Duration, }; -use anyhow::{bail, Error}; +use anyhow::{bail, format_err, Error}; use ldap3::adapters::{Adapter, EntriesOnly, PagedResults}; use ldap3::{Ldap, LdapConnAsync, LdapConnSettings, LdapResult, Scope, SearchEntry}; use native_tls::{Certificate, TlsConnector, TlsConnectorBuilder}; @@ -119,7 +119,11 @@ impl Connection { let mut ldap = self.create_connection().await?; if let Some(bind_dn) = self.config.bind_dn.as_deref() { - let password = self.config.bind_password.as_deref().unwrap_or_default(); + let password = self + .config + .bind_password + .as_deref() + .ok_or_else(|| format_err!("Missing bind password for {bind_dn}"))?; let _: LdapResult = ldap.simple_bind(bind_dn, password).await?.success()?; } @@ -254,7 +258,11 @@ impl Connection { let mut ldap = self.create_connection().await?; if let Some(bind_dn) = self.config.bind_dn.as_deref() { - let password = self.config.bind_password.as_deref().unwrap_or_default(); + let password = self + .config + .bind_password + .as_deref() + .ok_or_else(|| format_err!("Missing bind password for {bind_dn}"))?; let _: LdapResult = ldap.simple_bind(bind_dn, password).await?.success()?; let user_dn = self.do_search_user_dn(username, &mut ldap).await; -- 2.39.2