public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH datacenter-manager 0/4] views: verify digest, schema improvements
@ 2026-04-10 14:01 Lukas Wagner
  2026-04-10 14:01 ` [PATCH datacenter-manager 1/4] api: views: return config digest when retrieving views Lukas Wagner
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Lukas Wagner @ 2026-04-10 14:01 UTC (permalink / raw)
  To: pdm-devel

Lukas Wagner (4):
  api: views: return config digest when retrieving views
  ui: views: submit config digest when updating a view
  api: views: run API handlers in proxy process
  api: views: improve API schema definitions

 server/src/api/config/views.rs | 28 ++++++++++++----------------
 ui/src/configuration/views.rs  |  1 +
 2 files changed, 13 insertions(+), 16 deletions(-)

-- 
2.47.3





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH datacenter-manager 1/4] api: views: return config digest when retrieving views
  2026-04-10 14:01 [PATCH datacenter-manager 0/4] views: verify digest, schema improvements Lukas Wagner
@ 2026-04-10 14:01 ` Lukas Wagner
  2026-04-10 14:01 ` [PATCH datacenter-manager 2/4] ui: views: submit config digest when updating a view Lukas Wagner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Lukas Wagner @ 2026-04-10 14:01 UTC (permalink / raw)
  To: pdm-devel

This allows us to verify it later when PUTing a view config.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 server/src/api/config/views.rs | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/server/src/api/config/views.rs b/server/src/api/config/views.rs
index 6f187eb3..731f2a42 100644
--- a/server/src/api/config/views.rs
+++ b/server/src/api/config/views.rs
@@ -38,7 +38,7 @@ pub const ROUTER: Router = Router::new()
 )]
 /// List views.
 pub fn get_views(rpcenv: &mut dyn RpcEnvironment) -> Result<Vec<ViewConfig>, Error> {
-    let (config, _) = pdm_config::views::config()?;
+    let (config, config_digest) = pdm_config::views::config()?;
 
     let user_info = CachedUserInfo::new()?;
     let auth_id = rpcenv
@@ -65,6 +65,8 @@ pub fn get_views(rpcenv: &mut dyn RpcEnvironment) -> Result<Vec<ViewConfig>, Err
         })
         .collect();
 
+    rpcenv["digest"] = config_digest.to_hex().into();
+
     Ok(views)
 }
 
@@ -263,8 +265,8 @@ pub fn remove_view(id: String, digest: Option<ConfigDigest>) -> Result<(), Error
     returns: { type: ViewConfig },
 )]
 /// Get the config of a single view.
-pub fn read_view(id: String) -> Result<ViewConfig, Error> {
-    let (config, _) = pdm_config::views::config()?;
+pub fn read_view(id: String, rpcenv: &mut dyn RpcEnvironment) -> Result<ViewConfig, Error> {
+    let (config, config_digest) = pdm_config::views::config()?;
 
     let view = config
         .get(&id)
@@ -274,5 +276,7 @@ pub fn read_view(id: String) -> Result<ViewConfig, Error> {
         ViewConfigEntry::View(view) => view.clone(),
     };
 
+    rpcenv["digest"] = config_digest.to_hex().into();
+
     Ok(view)
 }
-- 
2.47.3





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH datacenter-manager 2/4] ui: views: submit config digest when updating a view
  2026-04-10 14:01 [PATCH datacenter-manager 0/4] views: verify digest, schema improvements Lukas Wagner
  2026-04-10 14:01 ` [PATCH datacenter-manager 1/4] api: views: return config digest when retrieving views Lukas Wagner
@ 2026-04-10 14:01 ` Lukas Wagner
  2026-04-10 14:01 ` [PATCH datacenter-manager 3/4] api: views: run API handlers in proxy process Lukas Wagner
  2026-04-10 14:01 ` [PATCH datacenter-manager 4/4] api: views: improve API schema definitions Lukas Wagner
  3 siblings, 0 replies; 5+ messages in thread
From: Lukas Wagner @ 2026-04-10 14:01 UTC (permalink / raw)
  To: pdm-devel

This ensures that the API can return an error in case somebody changed
the configuration in the meanwhile.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 ui/src/configuration/views.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ui/src/configuration/views.rs b/ui/src/configuration/views.rs
index 3f11911c..b8a1817d 100644
--- a/ui/src/configuration/views.rs
+++ b/ui/src/configuration/views.rs
@@ -192,6 +192,7 @@ impl ViewGridComp {
                 props.base_url,
                 percent_encode_component(&selection)
             ))
+            .submit_digest(true)
             .on_done(ctx.link().callback(|_| Msg::Reload))
             .into()
     }
-- 
2.47.3





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH datacenter-manager 3/4] api: views: run API handlers in proxy process
  2026-04-10 14:01 [PATCH datacenter-manager 0/4] views: verify digest, schema improvements Lukas Wagner
  2026-04-10 14:01 ` [PATCH datacenter-manager 1/4] api: views: return config digest when retrieving views Lukas Wagner
  2026-04-10 14:01 ` [PATCH datacenter-manager 2/4] ui: views: submit config digest when updating a view Lukas Wagner
@ 2026-04-10 14:01 ` Lukas Wagner
  2026-04-10 14:01 ` [PATCH datacenter-manager 4/4] api: views: improve API schema definitions Lukas Wagner
  3 siblings, 0 replies; 5+ messages in thread
From: Lukas Wagner @ 2026-04-10 14:01 UTC (permalink / raw)
  To: pdm-devel

The config is readable/writable by the unprivileged proxy user, so there
is no real reason why this needs to run in a privileged context.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 server/src/api/config/views.rs | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/server/src/api/config/views.rs b/server/src/api/config/views.rs
index 731f2a42..db68da5d 100644
--- a/server/src/api/config/views.rs
+++ b/server/src/api/config/views.rs
@@ -22,7 +22,6 @@ pub const ROUTER: Router = Router::new()
     .match_all("id", &VIEW_ROUTER);
 
 #[api(
-    protected: true,
     access: {
         permission: &Permission::Anybody,
         description: "Returns the views the user has access to.",
@@ -71,7 +70,6 @@ pub fn get_views(rpcenv: &mut dyn RpcEnvironment) -> Result<Vec<ViewConfig>, Err
 }
 
 #[api(
-    protected: true,
     input: {
         properties: {
             view: {
@@ -129,7 +127,6 @@ pub enum DeletableProperty {
 }
 
 #[api(
-    protected: true,
     input: {
         properties: {
             id: {
@@ -215,7 +212,6 @@ pub fn update_view(
 }
 
 #[api(
-    protected: true,
     input: {
         properties: {
             id: {
-- 
2.47.3





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH datacenter-manager 4/4] api: views: improve API schema definitions
  2026-04-10 14:01 [PATCH datacenter-manager 0/4] views: verify digest, schema improvements Lukas Wagner
                   ` (2 preceding siblings ...)
  2026-04-10 14:01 ` [PATCH datacenter-manager 3/4] api: views: run API handlers in proxy process Lukas Wagner
@ 2026-04-10 14:01 ` Lukas Wagner
  3 siblings, 0 replies; 5+ messages in thread
From: Lukas Wagner @ 2026-04-10 14:01 UTC (permalink / raw)
  To: pdm-devel

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 server/src/api/config/views.rs | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/server/src/api/config/views.rs b/server/src/api/config/views.rs
index db68da5d..e1da725d 100644
--- a/server/src/api/config/views.rs
+++ b/server/src/api/config/views.rs
@@ -8,7 +8,7 @@ use proxmox_schema::{api, param_bail};
 
 use pdm_api_types::{
     views::{ViewConfig, ViewConfigEntry, ViewConfigUpdater, ViewTemplate},
-    PRIV_RESOURCE_AUDIT, PRIV_RESOURCE_MODIFY,
+    PRIV_RESOURCE_AUDIT, PRIV_RESOURCE_MODIFY, VIEW_ID_SCHEMA,
 };
 
 const VIEW_ROUTER: Router = Router::new()
@@ -30,8 +30,7 @@ pub const ROUTER: Router = Router::new()
         description: "List of views.",
         type: Array,
         items: {
-            type: String,
-            description: "The name of a view."
+            type: ViewConfig,
         },
     },
 )]
@@ -130,8 +129,7 @@ pub enum DeletableProperty {
     input: {
         properties: {
             id: {
-                type: String,
-                description: "",
+                schema: VIEW_ID_SCHEMA,
             },
             view: {
                 flatten: true,
@@ -215,8 +213,7 @@ pub fn update_view(
     input: {
         properties: {
             id: {
-                type: String,
-                description: "",
+                schema: VIEW_ID_SCHEMA,
             },
             digest: {
                 type: ConfigDigest,
@@ -250,8 +247,7 @@ pub fn remove_view(id: String, digest: Option<ConfigDigest>) -> Result<(), Error
     input: {
         properties: {
             id: {
-                type: String,
-                description: "",
+                schema: VIEW_ID_SCHEMA,
             },
         },
     },
-- 
2.47.3





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-10 14:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-10 14:01 [PATCH datacenter-manager 0/4] views: verify digest, schema improvements Lukas Wagner
2026-04-10 14:01 ` [PATCH datacenter-manager 1/4] api: views: return config digest when retrieving views Lukas Wagner
2026-04-10 14:01 ` [PATCH datacenter-manager 2/4] ui: views: submit config digest when updating a view Lukas Wagner
2026-04-10 14:01 ` [PATCH datacenter-manager 3/4] api: views: run API handlers in proxy process Lukas Wagner
2026-04-10 14:01 ` [PATCH datacenter-manager 4/4] api: views: improve API schema definitions Lukas Wagner

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