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 91B2F1FF16B for ; Thu, 31 Oct 2024 14:46:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BA8E7AB31; Thu, 31 Oct 2024 14:46:42 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Thu, 31 Oct 2024 14:46:29 +0100 Message-Id: <20241031134629.144893-4-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241031134629.144893-1-d.kral@proxmox.com> References: <20241031134629.144893-1-d.kral@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.000 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 Subject: [pve-devel] [PATCH manager 4/4] ui: api token: allow unprivileged users to modify their own api tokens 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" Allows unprivileged users to edit and remove their own API tokens, as this is already allowed by the respective PUT and DELETE methods on the API endpoint `/access/users/{userid}/token/{tokenid}`. Signed-off-by: Daniel Kral --- As this cannot be seen in the diff directly: The run_editor is also used when double-clicking the record item (in addition when clicking the Edit button while the record item is selected). This has not been requested in the BugZilla #5722, but has similar intentions and made sense to include into this patch series as well. www/manager6/dc/TokenView.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/www/manager6/dc/TokenView.js b/www/manager6/dc/TokenView.js index d275a1c5..f71ab905 100644 --- a/www/manager6/dc/TokenView.js +++ b/www/manager6/dc/TokenView.js @@ -57,8 +57,12 @@ Ext.define('PVE.dc.TokenView', { return `/access/users/${uid}/token/${tid}`; }; + let hasTokenCRUDPermissions = function(userid) { + return userid === Proxmox.UserName || !!caps.access['User.Modify']; + }; + let run_editor = function(rec) { - if (!caps.access['User.Modify']) { + if (!hasTokenCRUDPermissions(rec.data.userid)) { return; } @@ -88,14 +92,14 @@ Ext.define('PVE.dc.TokenView', { xtype: 'proxmoxButton', text: gettext('Edit'), disabled: true, - enableFn: (rec) => !!caps.access['User.Modify'], + enableFn: (rec) => hasTokenCRUDPermissions(rec.data.userid), selModel: sm, handler: (btn, e, rec) => run_editor(rec), }, { xtype: 'proxmoxStdRemoveButton', selModel: sm, - enableFn: (rec) => !!caps.access['User.Modify'], + enableFn: (rec) => hasTokenCRUDPermissions(rec.data.userid), callback: reload, getUrl: urlFromRecord, }, -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel