public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dietmar Maurer <dietmar@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox] impl <T: UserInformation> UserInformation for std::sync::Arc<T>
Date: Thu, 16 Sep 2021 10:25:38 +0200	[thread overview]
Message-ID: <20210916082538.825118-1-dietmar@proxmox.com> (raw)

---
 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





                 reply	other threads:[~2021-09-16  8:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210916082538.825118-1-dietmar@proxmox.com \
    --to=dietmar@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal