From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 91DC71FF15E for ; Mon, 29 Sep 2025 17:48:29 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EA13016E0C; Mon, 29 Sep 2025 17:48:33 +0200 (CEST) From: Christian Ebner To: pdm-devel@lists.proxmox.com Date: Mon, 29 Sep 2025 17:48:16 +0200 Message-ID: <20250929154820.892720-3-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250929154820.892720-1-c.ebner@proxmox.com> References: <20250929154820.892720-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1759160890407 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.043 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 Subject: [pdm-devel] [PATCH proxmox 2/3] proxmox-client: adapt to new compat mode introduced for proxmox-login X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" The API for setting the compatibility changed to allow for easier extension. Adapt the client to the new interface and expose the same changes to the client. Also, re-export the `CompatMode` so users do not need to directly depend on the implementation in proxmox-login. Signed-off-by: Christian Ebner --- proxmox-client/src/client.rs | 12 ++++++------ proxmox-client/src/lib.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/proxmox-client/src/client.rs b/proxmox-client/src/client.rs index da2c5c59..894d9216 100644 --- a/proxmox-client/src/client.rs +++ b/proxmox-client/src/client.rs @@ -17,7 +17,7 @@ use serde::Serialize; use proxmox_http::Body; use proxmox_login::ticket::Validity; -use proxmox_login::{Login, SecondFactorChallenge, TicketResult}; +use proxmox_login::{CompatMode, Login, SecondFactorChallenge, TicketResult}; use crate::auth::AuthenticationKind; use crate::error::ParseFingerprintError; @@ -68,7 +68,7 @@ pub struct Client { api_url: Uri, auth: Mutex>>, client: Arc, - pve_compat: bool, + compat_mode: CompatMode, cookie_name: Option, } @@ -91,7 +91,7 @@ impl Client { api_url, auth: Mutex::new(None), client, - pve_compat: false, + compat_mode: CompatMode::default(), cookie_name: None, } } @@ -181,8 +181,8 @@ impl Client { /// Enable Proxmox VE login API compatibility. This is required to support TFA authentication /// on Proxmox VE APIs which require the `new-format` option. - pub fn set_pve_compatibility(&mut self, compatibility: bool) { - self.pve_compat = compatibility; + pub fn set_compatibility(&mut self, compat_mode: CompatMode) { + self.compat_mode = compat_mode; } pub fn set_cookie_name(&mut self, cookie_name: &str) { @@ -418,7 +418,7 @@ impl Client { /// If the authentication is complete, `None` is returned and the authentication state updated. /// If a 2nd factor is required, `Some` is returned. pub async fn login(&self, login: Login) -> Result, Error> { - let login = login.pve_compatibility(self.pve_compat); + let login = login.set_compatibility(self.compat_mode); let (ticket, api_response) = self.do_login_request(login.request()).await?; diff --git a/proxmox-client/src/lib.rs b/proxmox-client/src/lib.rs index f1df1e1d..3bac1333 100644 --- a/proxmox-client/src/lib.rs +++ b/proxmox-client/src/lib.rs @@ -12,7 +12,7 @@ mod error; pub use error::Error; pub use proxmox_login::tfa::TfaChallenge; -pub use proxmox_login::{Authentication, Ticket}; +pub use proxmox_login::{CompatMode, Authentication, Ticket}; mod api_path_builder; pub use api_path_builder::ApiPathBuilder; -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel