all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager 2/2] ui: token: add regenerate secret button
Date: Fri, 17 Apr 2026 14:35:04 +0200	[thread overview]
Message-ID: <20260417123504.143556-3-h.laimer@proxmox.com> (raw)
In-Reply-To: <20260417123504.143556-1-h.laimer@proxmox.com>

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 www/manager6/dc/TokenView.js | 37 ++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/www/manager6/dc/TokenView.js b/www/manager6/dc/TokenView.js
index b53cb888..8272729a 100644
--- a/www/manager6/dc/TokenView.js
+++ b/www/manager6/dc/TokenView.js
@@ -75,6 +75,26 @@ Ext.define('PVE.dc.TokenView', {
             win.show();
         };
 
+        let regenerate_token = function (_btn, _event, rec) {
+            if (!hasTokenCRUDPermissions(rec.data.userid)) {
+                return;
+            }
+            Proxmox.Utils.API2Request({
+                method: 'PUT',
+                url: urlFromRecord(rec),
+                params: { regenerate: 1 },
+                success: function (response) {
+                    Ext.create('PVE.dc.TokenShow', {
+                        autoShow: true,
+                        tokenid: response.result.data['full-tokenid'],
+                        secret: response.result.data.value,
+                    });
+                    reload();
+                },
+                failure: (res) => Ext.Msg.alert(gettext('Error'), res.htmlStatus),
+            });
+        };
+
         let tbar = [
             {
                 text: gettext('Add'),
@@ -104,6 +124,23 @@ Ext.define('PVE.dc.TokenView', {
                 getUrl: urlFromRecord,
             },
             '-',
+            {
+                xtype: 'proxmoxButton',
+                text: gettext('Regenerate Secret'),
+                disabled: true,
+                selModel: sm,
+                enableFn: (rec) => hasTokenCRUDPermissions(rec.data.userid),
+                dangerous: true,
+                confirmMsg: (rec) =>
+                    Ext.String.format(
+                        gettext(
+                            "Regenerate the secret of the API token '{0}'? All users of the previous token secret will lose access!",
+                        ),
+                        rec.data.id,
+                    ),
+                handler: regenerate_token,
+            },
+            '-',
             {
                 xtype: 'proxmoxButton',
                 text: gettext('Show Permissions'),
-- 
2.47.3





      parent reply	other threads:[~2026-04-17 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17 12:35 [PATCH access-control/manager 0/2] fixes #7504: add support for regenerating secrets Hannes Laimer
2026-04-17 12:35 ` [PATCH pve-access-control 1/2] api: token: support regenerating the secret on update Hannes Laimer
2026-04-17 12:35 ` Hannes Laimer [this message]

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=20260417123504.143556-3-h.laimer@proxmox.com \
    --to=h.laimer@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