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 7964B1FF191 for ; Tue, 4 Nov 2025 10:30:02 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AC728801C; Tue, 4 Nov 2025 10:30:41 +0100 (CET) Mime-Version: 1.0 Date: Tue, 04 Nov 2025 10:30:38 +0100 Message-Id: To: "Lukas Wagner" , "Proxmox Datacenter Manager development discussion" From: "Shan Shaji" X-Mailer: aerc 0.20.0 References: <20251017130217.160313-1-s.shaji@proxmox.com> <20251017130217.160313-2-s.shaji@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762248621406 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.024 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 POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pdm-devel] [PATCH datacenter-manager v2 1/3] fix #6901: api: add explicit permission check for controllers list 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" On Mon Nov 3, 2025 at 2:40 PM CET, Lukas Wagner wrote: > Hi Shan, thanks a lot for the patch! > > One comment inline, apart from that it looks good to me. > > On Fri Oct 17, 2025 at 3:02 PM CEST, Shan Shaji wrote: >> When a non-root user tried to access the EVPN section, the API was >> throwing "403: permission check failed" error. To fix this, add >> explicit permission check for the `/controller` endpoint. >> >> Now every authenticated user can access the endpoint however, the user >> needs to have at least `Resource.Audit` permission under `/resource`. >> Only the controllers from remotes which the user has `Resource.Audit` >> privilege on `/remote/{remote_name}` will be included in the returned >> list. >> >> Signed-off-by: Shan Shaji >> --- >> server/src/api/sdn/controllers.rs | 30 ++++++++++++++++++++++++++---- >> 1 file changed, 26 insertions(+), 4 deletions(-) >> >> diff --git a/server/src/api/sdn/controllers.rs b/server/src/api/sdn/controllers.rs >> index 271397a..649d668 100644 >> --- a/server/src/api/sdn/controllers.rs >> +++ b/server/src/api/sdn/controllers.rs >> @@ -1,10 +1,11 @@ >> use std::collections::HashSet; >> >> -use anyhow::Error; >> +use anyhow::{format_err, Error}; >> >> use pbs_api_types::REMOTE_ID_SCHEMA; >> -use pdm_api_types::{remotes::RemoteType, sdn::ListController}; >> -use proxmox_router::Router; >> +use pdm_api_types::{remotes::RemoteType, sdn::ListController, Authid, PRIV_RESOURCE_AUDIT}; >> +use proxmox_access_control::CachedUserInfo; >> +use proxmox_router::{http_bail, Permission, Router, RpcEnvironment}; >> use proxmox_schema::api; >> use pve_api_types::ListControllersType; >> >> @@ -49,6 +50,12 @@ pub const ROUTER: Router = Router::new().get(&API_METHOD_LIST_CONTROLLERS); >> type: ListController, >> }, >> }, >> + access: { >> + permission: &Permission::Anybody, >> + description: "The user needs to have at least the `Resource.Audit` privilege under `/resource`. >> + Only controllers from remotes for which the user has `Resource.Audit` on `/remote/{remote_name}` > > I think there is a typo here, as far as I can tell the ACL path should > be /resource/{remote_name}? Also applies to the other two patches. Hi Lukas, Thank you so much for the review. I will send an updated patch. > >> + will be included in the returned list." >> + } >> )] >> /// Query controllers of remotes with optional filtering options >> pub async fn list_controllers( >> @@ -56,10 +63,25 @@ pub async fn list_controllers( >> running: Option, >> ty: Option, >> remotes: Option>, >> + rpcenv: &mut dyn RpcEnvironment, >> ) -> Result, Error> { >> + let user_info = CachedUserInfo::new()?; >> + >> + let auth_id: Authid = rpcenv >> + .get_auth_id() >> + .ok_or_else(|| format_err!("no authid available"))? >> + .parse()?; >> + >> + if !user_info.any_privs_below(&auth_id, &["resource"], PRIV_RESOURCE_AUDIT)? { >> + http_bail!(FORBIDDEN, "user has no access to resources"); >> + } >> + >> let (remote_config, _) = pdm_config::remotes::config()?; >> + let authorized_remotes = remote_config.into_iter().filter(|(remote_name, _)| { >> + user_info.lookup_privs(&auth_id, &["resource", &remote_name]) & PRIV_RESOURCE_AUDIT != 0 >> + }); >> >> - let filtered_remotes = remote_config.into_iter().filter_map(|(_, remote)| { >> + let filtered_remotes = authorized_remotes.filter_map(|(_, remote)| { >> if remote.ty == RemoteType::Pve >> && remotes >> .as_ref() _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel