From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager] api: remote tasks: add fine-grained permission check on the remote level
Date: Fri, 28 Nov 2025 16:15:50 +0100 [thread overview]
Message-ID: <20251128151550.369432-1-l.wagner@proxmox.com> (raw)
Adds a check for the remote task APIs that requires a user to have
Resource.Audit on /resource/{remote}.
Could make sense to a.) verify permissions on the node-level (we do so
in PVE) and b.) allow a user to see their own tasks. But we can do that
later as well, more important for now is getting rid of the bare
Permission::Anybody.
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
server/src/api/remote_tasks.rs | 32 ++++++++++++++++++++++++++------
server/src/remote_tasks/mod.rs | 5 +++++
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/server/src/api/remote_tasks.rs b/server/src/api/remote_tasks.rs
index 02b6383b..1dff4bd6 100644
--- a/server/src/api/remote_tasks.rs
+++ b/server/src/api/remote_tasks.rs
@@ -27,10 +27,9 @@ const SUBDIRS: SubdirMap = &sorted!([
]);
#[api(
- // FIXME:: see list-like API calls in resource routers, we probably want more fine-grained
- // checks..
access: {
permission: &Permission::Anybody,
+ description: "Resource.Audit privileges on /resource/{remote} are needed to list tasks from a given remote."
},
input: {
properties: {
@@ -64,16 +63,26 @@ async fn list_tasks(
user_info.check_privs(&auth_id, &["view", view], PRIV_RESOURCE_AUDIT, false)?;
}
- let tasks = remote_tasks::get_tasks(filters, remote, view).await?;
+ let check_privs = move |remote_name: &str| {
+ user_info
+ .check_privs(
+ &auth_id,
+ &["resource", remote_name],
+ PRIV_RESOURCE_AUDIT,
+ false,
+ )
+ .is_ok()
+ };
+
+ let tasks = remote_tasks::get_tasks(filters, remote, check_privs, view).await?;
Ok(tasks)
}
#[api(
- // FIXME:: see list-like API calls in resource routers, we probably want more fine-grained
- // checks..
access: {
permission: &Permission::Anybody,
+ description: "Resource.Audit privileges on /resource/{remote} are needed to list tasks from a given remote."
},
input: {
properties: {
@@ -106,7 +115,18 @@ async fn task_statistics(
user_info.check_privs(&auth_id, &["view", view], PRIV_RESOURCE_AUDIT, false)?;
}
- let tasks = remote_tasks::get_tasks(filters, remote, view).await?;
+ let check_privs = move |remote_name: &str| {
+ user_info
+ .check_privs(
+ &auth_id,
+ &["resource", remote_name],
+ PRIV_RESOURCE_AUDIT,
+ false,
+ )
+ .is_ok()
+ };
+
+ let tasks = remote_tasks::get_tasks(filters, remote, check_privs, view).await?;
let mut by_type: HashMap<String, TaskCount> = HashMap::new();
let mut by_remote: HashMap<String, TaskCount> = HashMap::new();
diff --git a/server/src/remote_tasks/mod.rs b/server/src/remote_tasks/mod.rs
index ea3c5539..b080811f 100644
--- a/server/src/remote_tasks/mod.rs
+++ b/server/src/remote_tasks/mod.rs
@@ -31,6 +31,7 @@ const NUMBER_OF_UNCOMPRESSED_FILES: u32 = 2;
pub async fn get_tasks(
filters: TaskFilters,
remote_filter: Option<String>,
+ check_privs: impl Fn(&str) -> bool + Send + 'static,
view: Option<String>,
) -> Result<Vec<TaskListItem>, Error> {
let view = views::get_optional_view(view.as_deref())?;
@@ -64,6 +65,8 @@ pub async fn get_tasks(
if !view.is_node_included(task.upid.remote(), &pve_upid.node) {
return None;
}
+ } else if !check_privs(task.upid.remote()) {
+ return None;
}
Some(TaskListItem {
upid: task.upid.to_string(),
@@ -83,6 +86,8 @@ pub async fn get_tasks(
if !view.is_node_included(task.upid.remote(), &pbs_upid.node) {
return None;
}
+ } else if !check_privs(task.upid.remote()) {
+ return None;
}
Some(TaskListItem {
upid: task.upid.to_string(),
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next reply other threads:[~2025-11-28 15:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 15:15 Lukas Wagner [this message]
2025-11-28 18:53 ` [pdm-devel] applied: " Thomas Lamprecht
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=20251128151550.369432-1-l.wagner@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pdm-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 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.