From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id D5E831FF09D for ; Sun, 15 Nov 2026 20:43:02 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9D42821893; Sun, 15 Nov 2026 20:41:09 +0100 (CET) From: Thomas Lamprecht 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 Message-ID: <20261115194043.3947825-16-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261115194043.3947825-1-t.lamprecht@proxmox.com> References: <20261115194043.3947825-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794771649997 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.226 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: Y2S7WSPAQWXGKFARU7NUNRC6E4WY4F4R X-Message-ID-Hash: Y2S7WSPAQWXGKFARU7NUNRC6E4WY4F4R X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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