From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id B64BB1FF09D for ; Sun, 15 Nov 2026 20:41:03 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 230EB215E9; Sun, 15 Nov 2026 20:41:01 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH v2 cluster 3/19] datacenter config: token policy: allow extension on regeneration Date: Sun, 15 Nov 2026 20:40:24 +0100 Message-ID: <20261115194043.3947825-4-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: 1794771649187 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.231 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: CXGOF4YVG2KKFRRGU6IPGKZGKZN3MBPP X-Message-ID-Hash: CXGOF4YVG2KKFRRGU6IPGKZGKZN3MBPP 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: With 'disallow-expiry-extension' set, keeping an integration running past the maximum lifetime needs a new token with all its permissions set up again. As creating that token is always possible, the restriction mostly adds work and discourages narrowly scoped tokens. Extending a token together with regenerating its secret has the same effect as recreating it, as the old credential stops working. Add a setting that allows exactly that, so tools can rotate their tokens in place, within the maximum lifetime. Suggested-by: Shannon Sterz Signed-off-by: Thomas Lamprecht --- new in v2 src/PVE/DataCenterConfig.pm | 8 ++++++++ src/test/test_token_policy.pl | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/PVE/DataCenterConfig.pm b/src/PVE/DataCenterConfig.pm index 330126b..49d1bb6 100644 --- a/src/PVE/DataCenterConfig.pm +++ b/src/PVE/DataCenterConfig.pm @@ -303,6 +303,14 @@ my $token_policy_format = { . " lifetime instead of rejecting them, for example for tools unaware of the policy." . " Has no effect without 'max-lifetime'.", }, + 'allow-extension-on-regenerate' => { + type => 'boolean', + optional => 1, + default => 0, + description => "Allow extending the expiration date of an existing API token when its" + . " secret is regenerated in the same request, despite 'disallow-expiry-extension'." + . " The maximum lifetime still applies.", + }, 'require-privilege-separation' => { type => 'boolean', optional => 1, diff --git a/src/test/test_token_policy.pl b/src/test/test_token_policy.pl index bcafec1..adcb93a 100644 --- a/src/test/test_token_policy.pl +++ b/src/test/test_token_policy.pl @@ -26,6 +26,9 @@ is($policy->{'require-privilege-separation'}, 1, 'require-privilege-separation i $policy = $parse->('max-lifetime=86400,default-to-max-lifetime=1')->{'token-policy'}; is($policy->{'default-to-max-lifetime'}, 1, 'default-to-max-lifetime is parsed'); +$policy = $parse->('disallow-expiry-extension=1,allow-extension-on-regenerate=1')->{'token-policy'}; +is($policy->{'allow-extension-on-regenerate'}, 1, 'allow-extension-on-regenerate is parsed'); + is($parse->(undef)->{'token-policy'}, undef, 'an absent token-policy is not invented'); # an unusable policy has to be dropped, never half applied, and must not take the rest of the -- 2.47.3