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 6ACC61FF165 for ; Thu, 28 Aug 2025 12:59:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DA319DAC0; Thu, 28 Aug 2025 12:59:48 +0200 (CEST) From: Shannon Sterz To: pdm-devel@lists.proxmox.com Date: Thu, 28 Aug 2025 12:59:04 +0200 Message-ID: <20250828105912.294887-4-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250828105912.294887-1-s.sterz@proxmox.com> References: <20250828105912.294887-1-s.sterz@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1756378748754 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 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: [pdm-devel] [PATCH proxmox v3 3/6] access-control: add comments to roles function of AccessControlConfig 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" this will allow us to implement a generic `roles()` endpoint similar to the one proxmox backup server already has at `/access/roles` and that proxmox-yew-comp's `RoleSelector` already relies on. Signed-off-by: Shannon Sterz --- proxmox-access-control/src/acl.rs | 12 ++++++------ proxmox-access-control/src/cached_user_info.rs | 4 ++-- proxmox-access-control/src/init.rs | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/proxmox-access-control/src/acl.rs b/proxmox-access-control/src/acl.rs index b8041688..270292ac 100644 --- a/proxmox-access-control/src/acl.rs +++ b/proxmox-access-control/src/acl.rs @@ -647,11 +647,11 @@ mod test { #[derive(Debug)] struct TestAcmConfig<'a> { - roles: HashMap<&'a str, u64>, + roles: HashMap<&'a str, (u64, &'a str)>, } impl AccessControlConfig for TestAcmConfig<'_> { - fn roles(&self) -> &HashMap<&str, u64> { + fn roles(&self) -> &HashMap<&str, (u64, &str)> { &self.roles } @@ -672,10 +672,10 @@ mod test { static ACL_CONFIG: OnceLock = OnceLock::new(); let config = ACL_CONFIG.get_or_init(|| { let mut roles = HashMap::new(); - roles.insert("NoAccess", 0); - roles.insert("Admin", u64::MAX); - roles.insert("DatastoreBackup", 4); - roles.insert("DatastoreReader", 8); + roles.insert("NoAccess", (0, "comment")); + roles.insert("Admin", (u64::MAX, "comment")); + roles.insert("DatastoreBackup", (4, "comment")); + roles.insert("DatastoreReader", (8, "comment")); TestAcmConfig { roles } }); diff --git a/proxmox-access-control/src/cached_user_info.rs b/proxmox-access-control/src/cached_user_info.rs index 4d011f00..f5ed2858 100644 --- a/proxmox-access-control/src/cached_user_info.rs +++ b/proxmox-access-control/src/cached_user_info.rs @@ -150,7 +150,7 @@ impl CachedUserInfo { if self.is_superuser(auth_id) { let acm_config = access_conf(); if let Some(admin) = acm_config.role_admin() { - if let Some(admin) = acm_config.roles().get(admin) { + if let Some((admin, _)) = acm_config.roles().get(admin) { return (*admin, *admin); } } @@ -160,7 +160,7 @@ impl CachedUserInfo { let mut privs: u64 = 0; let mut propagated_privs: u64 = 0; for (role, propagate) in roles { - if let Some(role_privs) = access_conf().roles().get(role.as_str()) { + if let Some((role_privs, _)) = access_conf().roles().get(role.as_str()) { if propagate { propagated_privs |= role_privs; } diff --git a/proxmox-access-control/src/init.rs b/proxmox-access-control/src/init.rs index a6d36780..c219a78e 100644 --- a/proxmox-access-control/src/init.rs +++ b/proxmox-access-control/src/init.rs @@ -16,8 +16,9 @@ pub trait AccessControlConfig: Send + Sync { /// Returns a mapping of all recognized privileges and their corresponding `u64` value. fn privileges(&self) -> &HashMap<&str, u64>; - /// Returns a mapping of all recognized roles and their corresponding `u64` value. - fn roles(&self) -> &HashMap<&str, u64>; + /// Returns a mapping of all recognized roles and their corresponding `u64` value as well as + /// a comment. + fn roles(&self) -> &HashMap<&str, (u64, &str)>; /// Checks whether an `Authid` has super user privileges or not. /// -- 2.47.2 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel