all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox] impl <T: UserInformation> UserInformation for std::sync::Arc<T>
@ 2021-09-16  8:25 Dietmar Maurer
  0 siblings, 0 replies; only message in thread
From: Dietmar Maurer @ 2021-09-16  8:25 UTC (permalink / raw)
  To: pbs-devel

---
 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 5792c8f..b55bcd5 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 <T: UserInformation> UserInformation for std::sync::Arc<T> {
+    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
-- 
2.30.2





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-16  8:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16  8:25 [pbs-devel] [PATCH proxmox] impl <T: UserInformation> UserInformation for std::sync::Arc<T> Dietmar Maurer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal