From fb2b7a4e93b5b2a8f0356a1b130cad0c8f3fd0f4 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 16 Sep 2021 10:21:50 +0200 Subject: [PATCH] impl UserInformation for std::sync::Arc --- proxmox/src/api/permission.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/proxmox/src/api/permission.rs b/proxmox/src/api/permission.rs index 5792c8f9..b55bcd54 100644 --- a/proxmox/src/api/permission.rs +++ b/proxmox/src/api/permission.rs @@ -4,6 +4,7 @@ use std::collections::HashMap; use std::fmt; +use std::ops::Deref; /// Access permission #[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))] @@ -72,6 +73,18 @@ pub trait UserInformation { fn lookup_privs(&self, userid: &str, path: &[&str]) -> u64; } +impl UserInformation for std::sync::Arc { + fn is_superuser(&self, userid: &str) -> bool { + self.deref().is_superuser(userid) + } + fn is_group_member(&self, userid: &str, group: &str) -> bool { + self.deref().is_group_member(userid, group) + } + fn lookup_privs(&self, userid: &str, path: &[&str]) -> u64 { + self.deref().lookup_privs(userid, path) + } +} + /// Example implementation to check access permissions /// /// This implementation supports URI variables in Privilege path