all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH common v4 1/1] json schema/rest environment: add 'expose_credentials' option
Date: Fri, 14 Nov 2025 15:59:17 +0100	[thread overview]
Message-ID: <20251114145927.3766668-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20251114145927.3766668-1-d.csapak@proxmox.com>

this is used to mark api calls to have access to the credentials
of the connection (token/ticket/etc.).

For that we also expose a 'set/get_credentials' call on the
RESTEnvironment.

This must be set in the http/cli handler.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PVE/JSONSchema.pm      |  8 ++++++++
 src/PVE/RESTEnvironment.pm | 14 ++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index c6e0f36..8278899 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -1850,6 +1850,14 @@ my $method_schema = {
             description => "Method needs special privileges - only pvedaemon can execute it",
             optional => 1,
         },
+        expose_credentials => {
+            type => 'boolean',
+            description => "Method needs access to the connecting users credentials (ticker or"
+                . " token), so it will be exposed through the RPC environment. Useful to avoid"
+                . " setting 'protected' when one needs to (manually) proxy to other cluster nodes."
+                . " nodes in the handler.",
+            optional => 1,
+        },
         allowtoken => {
             type => 'boolean',
             description => "Method is available for clients authenticated using an API token.",
diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
index 7695850..d597557 100644
--- a/src/PVE/RESTEnvironment.pm
+++ b/src/PVE/RESTEnvironment.pm
@@ -235,6 +235,20 @@ sub get_user {
     die "user name not set\n";
 }
 
+sub set_credentials {
+    my ($self, $credentials) = @_;
+
+    $self->{credentials} = $credentials;
+}
+
+sub get_credentials {
+    my ($self, $noerr) = @_;
+
+    return $self->{credentials} if defined($self->{credentials}) || $noerr;
+
+    die "credentials not set\n";
+}
+
 sub set_u2f_challenge {
     my ($self, $challenge) = @_;
 
-- 
2.47.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-11-14 14:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-14 14:59 [pve-devel] [PATCH apiclient/common/manager v4 0/5] implement cluster-wide bulk-actions for guests Dominik Csapak
2025-11-14 14:59 ` [pve-devel] [PATCH pve-apiclient v4 1/1] try to refresh ticket before an api call Dominik Csapak
2025-11-14 21:09   ` [pve-devel] applied: " Thomas Lamprecht
2025-11-14 14:59 ` Dominik Csapak [this message]
2025-11-14 14:59 ` [pve-devel] [PATCH manager v4 1/3] http server/pvesh: set credentials if necessary Dominik Csapak
2025-11-14 21:02   ` [pve-devel] applied: " Thomas Lamprecht
2025-11-14 14:59 ` [pve-devel] [PATCH manager v4 2/3] api: implement node-independent bulk actions Dominik Csapak
2025-11-14 21:02   ` [pve-devel] applied: " Thomas Lamprecht
2025-11-14 14:59 ` [pve-devel] [PATCH manager v4 3/3] ui: add bulk actions to the datacenter level Dominik Csapak
2025-11-14 21:02   ` [pve-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=20251114145927.3766668-3-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal