all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v2 manager 15/19] ui: token policy: allow extension on secret regeneration
Date: Sun, 15 Nov 2026 20:40:36 +0100	[thread overview]
Message-ID: <20261115194043.3947825-16-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261115194043.3947825-1-t.lamprecht@proxmox.com>

Expose the new allow-extension-on-regenerate setting in the datacenter
options, enabled only while extending is disallowed in general as it
has no effect otherwise, and offer a 'Regenerate Secret' checkbox in
the token edit dialog when the policy allows extending that way.
Ticking it lifts the bound by the current expiration date, the maximum
lifetime still applies, and the new secret is shown after saving like
for the separate regenerate action. As that action asks for
confirmation, a hint below the checkbox states that the current secret
stops working.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---

new in v2

 www/manager6/dc/OptionView.js | 32 ++++++++++++++++++++++++++++++++
 www/manager6/dc/TokenEdit.js  | 29 +++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js
index 38b4e8d6e..b9db5a729 100644
--- a/www/manager6/dc/OptionView.js
+++ b/www/manager6/dc/OptionView.js
@@ -407,6 +407,9 @@ Ext.define('PVE.dc.OptionView', {
                 if (Number(policy['disallow-expiry-extension'])) {
                     parts.push(gettext('Disallow Extending Expiration'));
                 }
+                if (Number(policy['allow-extension-on-regenerate'])) {
+                    parts.push(gettext('Allow Extension on Regeneration'));
+                }
                 if (Number(policy['require-privilege-separation'])) {
                     parts.push(gettext('Require Privilege Separation'));
                 }
@@ -455,6 +458,9 @@ Ext.define('PVE.dc.OptionView', {
                             if (values['disallow-expiry-extension']) {
                                 policy['disallow-expiry-extension'] = 1;
                             }
+                            if (values['allow-extension-on-regenerate']) {
+                                policy['allow-extension-on-regenerate'] = 1;
+                            }
                             if (values['require-privilege-separation']) {
                                 policy['require-privilege-separation'] = 1;
                             }
@@ -534,6 +540,32 @@ Ext.define('PVE.dc.OptionView', {
                                 name: 'disallow-expiry-extension',
                                 uncheckedValue: 0,
                                 fieldLabel: gettext('Disallow Extending Expiration'),
+                                listeners: {
+                                    // allowing an extension on regeneration only makes sense
+                                    // while extending is disallowed in general
+                                    change: function (field, value) {
+                                        let allowOnRegenerate = field
+                                            .up('inputpanel')
+                                            .down('field[name=allow-extension-on-regenerate]');
+                                        allowOnRegenerate.setDisabled(!value);
+                                        if (!value) {
+                                            allowOnRegenerate.setValue(false);
+                                        }
+                                    },
+                                },
+                            },
+                            {
+                                xtype: 'proxmoxcheckbox',
+                                name: 'allow-extension-on-regenerate',
+                                uncheckedValue: 0,
+                                disabled: true,
+                                fieldLabel: gettext('Allow Extension on Regeneration'),
+                                autoEl: {
+                                    tag: 'div',
+                                    'data-qtip': gettext(
+                                        'Allow extending the expiration date of a token when its secret is regenerated at the same time.',
+                                    ),
+                                },
                             },
                             {
                                 xtype: 'proxmoxcheckbox',
diff --git a/www/manager6/dc/TokenEdit.js b/www/manager6/dc/TokenEdit.js
index ad31db929..e0dd0d0fd 100644
--- a/www/manager6/dc/TokenEdit.js
+++ b/www/manager6/dc/TokenEdit.js
@@ -105,6 +105,24 @@ Ext.define('PVE.dc.TokenEdit', {
                 minValue: 1,
                 fieldLabel: gettext('Lifetime (seconds)'),
             },
+            {
+                // offered when the policy allows extending the expiration date along with it
+                xtype: 'proxmoxcheckbox',
+                name: 'regenerate',
+                hidden: true,
+                disabled: true,
+                fieldLabel: gettext('Regenerate Secret'),
+                boxLabel: gettext('allows extending the expiration date'),
+            },
+            {
+                xtype: 'displayfield',
+                itemId: 'regenerateHint',
+                userCls: 'pmx-hint',
+                hidden: true,
+                value: gettext(
+                    'After saving, the current secret stops working and the new one is shown.',
+                ),
+            },
         ],
         columnB: [
             {
@@ -191,6 +209,16 @@ Ext.define('PVE.dc.TokenEdit', {
 
         // the policy may forbid moving the expiration date later or removing it
         let noExtension = !!Number(me.policy['disallow-expiry-extension']) && !!me.originalExpire;
+        if (noExtension && Number(me.policy['allow-extension-on-regenerate'])) {
+            let regenerateField = me.down('field[name=regenerate]');
+            let regenerateHint = me.down('#regenerateHint');
+            regenerateField.setVisible(true);
+            regenerateField.setDisabled(false);
+            regenerateField.on('change', (_field, regenerate) => {
+                regenerateHint.setVisible(regenerate);
+                me.applyExpiryBounds(!regenerate);
+            });
+        }
         me.applyExpiryBounds(noExtension);
     },
 
@@ -238,6 +266,7 @@ Ext.define('PVE.dc.TokenEdit', {
             bound = current;
         }
         expireField.setMaxValue(bound);
+        expireField.validate();
     },
 
     setValues: function (values) {
-- 
2.47.3





  parent reply	other threads:[~2026-11-15 19:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 19:40 [PATCH v2 cluster/access-control/docs/manager/proxmox 0/19] fix #7805: add a datacenter-wide API token policy Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 cluster 1/19] datacenter config: add token-policy option Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 cluster 2/19] datacenter config: token policy: add default-to-max-lifetime setting Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 cluster 3/19] datacenter config: token policy: allow extension on regeneration Thomas Lamprecht
2026-11-17 13:30   ` Shannon Sterz
2026-11-15 19:40 ` [PATCH v2 access-control 4/19] fix #7805: api: token: enforce datacenter token policy Thomas Lamprecht
2026-11-17 13:30   ` Shannon Sterz
2026-11-15 19:40 ` [PATCH v2 access-control 5/19] api: token: apply the default lifetime from the " Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 access-control 6/19] api: token: allow extending tokens on secret regeneration Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 docs 7/19] user management: document the API token policy Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 docs 8/19] user management: document the default-to-max-lifetime setting Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 docs 9/19] user management: document extending tokens on secret regeneration Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 manager 10/19] ui: token edit: only submit the expiration date when changed Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 manager 11/19] api: cluster options: return token-policy without Sys.Audit Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 manager 12/19] ui: dc options: allow editing the API token policy Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 manager 13/19] ui: token edit: adapt to the datacenter " Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 manager 14/19] ui: token policy: expose the default-to-max-lifetime setting Thomas Lamprecht
2026-11-15 19:40 ` Thomas Lamprecht [this message]
2026-11-15 19:40 ` [PATCH v2 proxmox 16/19] access-control: add API token policy type with expiry checks Thomas Lamprecht
2026-11-17 13:29   ` Shannon Sterz
2026-11-15 19:40 ` [PATCH v2 proxmox 17/19] access-control: enforce token policy on token create and update Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 proxmox 18/19] access-control: apply a default token lifetime from the policy Thomas Lamprecht
2026-11-15 19:40 ` [PATCH v2 proxmox 19/19] access-control: allow extending tokens on secret regeneration Thomas Lamprecht
2026-11-17 13:29   ` Shannon Sterz
2026-11-17 13:29 ` [PATCH v2 cluster/access-control/docs/manager/proxmox 0/19] fix #7805: add a datacenter-wide API token policy Shannon Sterz
2026-11-18  2:17 ` 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=20261115194043.3947825-16-t.lamprecht@proxmox.com \
    --to=t.lamprecht@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