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 ACC461FF09D for ; Sun, 15 Nov 2026 20:41:20 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 086462168F; Sun, 15 Nov 2026 20:41:02 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH v2 cluster 2/19] datacenter config: token policy: add default-to-max-lifetime setting Date: Sun, 15 Nov 2026 20:40:23 +0100 Message-ID: <20261115194043.3947825-3-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: 1794771649125 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: HZQVTMLGCSRBTC4KFWRTABERYQ6YOWAK X-Message-ID-Hash: HZQVTMLGCSRBTC4KFWRTABERYQ6YOWAK 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 'max-lifetime' set, a token created without an expiration date is rejected. That breaks tools unaware of the policy, like the remote wizard of Proxmox Datacenter Manager, and makes onboarding them cumbersome, as a compliant token must be created by hand first. Add a setting that gives such tokens the maximum lifetime instead, so a missing expiration date no longer gets them rejected. It is opt-in, as a token expiring without the client asking for it can break that client later instead. The enforcement side applies it on token creation only. Suggested-by: Shannon Sterz Signed-off-by: Thomas Lamprecht --- new in v2 src/PVE/DataCenterConfig.pm | 9 +++++++++ src/test/test_token_policy.pl | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/PVE/DataCenterConfig.pm b/src/PVE/DataCenterConfig.pm index 13d388f..330126b 100644 --- a/src/PVE/DataCenterConfig.pm +++ b/src/PVE/DataCenterConfig.pm @@ -294,6 +294,15 @@ my $token_policy_format = { . " repeatedly. Shortening it, or setting one for a token without, stays possible," . " and tokens can still be deleted and recreated.", }, + 'default-to-max-lifetime' => { + type => 'boolean', + optional => 1, + default => 0, + description => + "Set the expiration date of API tokens created without one to the maximum" + . " lifetime instead of rejecting them, for example for tools unaware of the policy." + . " Has no effect without 'max-lifetime'.", + }, 'require-privilege-separation' => { type => 'boolean', optional => 1, diff --git a/src/test/test_token_policy.pl b/src/test/test_token_policy.pl index 0128aad..bcafec1 100644 --- a/src/test/test_token_policy.pl +++ b/src/test/test_token_policy.pl @@ -23,6 +23,9 @@ $policy = $parse->('disallow-expiry-extension=1,require-privilege-separation=1') is($policy->{'disallow-expiry-extension'}, 1, 'disallow-expiry-extension is parsed'); is($policy->{'require-privilege-separation'}, 1, 'require-privilege-separation is parsed'); +$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'); + 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