From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 5E14B1FF15C for ; Fri, 14 Nov 2025 15:59:07 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1F3F0164F8; Fri, 14 Nov 2025 16:00:03 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Fri, 14 Nov 2025 15:59:17 +0100 Message-ID: <20251114145927.3766668-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251114145927.3766668-1-d.csapak@proxmox.com> References: <20251114145927.3766668-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [jsonschema.pm, restenvironment.pm] Subject: [pve-devel] [PATCH common v4 1/1] json schema/rest environment: add 'expose_credentials' option X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" 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 --- 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