From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <w.bumiller@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id B455B7D71A
 for <pve-devel@lists.proxmox.com>; Tue,  9 Nov 2021 12:27:53 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id EB051AFF4
 for <pve-devel@lists.proxmox.com>; Tue,  9 Nov 2021 12:27:27 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 8B258AF81
 for <pve-devel@lists.proxmox.com>; Tue,  9 Nov 2021 12:27:25 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 60C5C46873
 for <pve-devel@lists.proxmox.com>; Tue,  9 Nov 2021 12:27:25 +0100 (CET)
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Tue,  9 Nov 2021 12:27:06 +0100
Message-Id: <20211109112721.130935-18-w.bumiller@proxmox.com>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20211109112721.130935-1-w.bumiller@proxmox.com>
References: <20211109112721.130935-1-w.bumiller@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.541 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [datacenterconfig.pm]
Subject: [pve-devel] [PATCH cluster] add webauthn configuration to
 datacenter.cfg
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Tue, 09 Nov 2021 11:27:53 -0000

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
 data/PVE/DataCenterConfig.pm | 43 ++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/data/PVE/DataCenterConfig.pm b/data/PVE/DataCenterConfig.pm
index fa8ba4a..2e802d3 100644
--- a/data/PVE/DataCenterConfig.pm
+++ b/data/PVE/DataCenterConfig.pm
@@ -66,6 +66,34 @@ my $u2f_format = {
     },
 };
 
+my $webauthn_format = {
+    rp => {
+	type => 'string',
+	description =>
+	    'Relying party name. Any text identifier.'
+	    .' Changing this *may* break existing credentials.',
+	format_description => 'RELYING_PARTY',
+	optional => 1,
+    },
+    origin => {
+	type => 'string',
+	description =>
+	    'Site origin. Must be a `https://` URL (or `http://localhost`).'
+	    .' Should contain the address users type in their browsers to access'
+	    .' the web interface.'
+	    .' Changing this *may* break existing credentials.',
+	format_description => 'URL',
+	optional => 1,
+    },
+    id => {
+	type => 'string',
+	description =>
+	    'Relying part ID. Must be the domain name without protocol, port or location.'
+	    .' Changing this *will* break existing credentials.',
+	format_description => 'DOMAINNAME',
+	optional => 1,
+    },
+};
 
 PVE::JSONSchema::register_format('mac-prefix', \&pve_verify_mac_prefix);
 sub pve_verify_mac_prefix {
@@ -181,6 +209,12 @@ my $datacenter_schema = {
 	    format => $u2f_format,
 	    description => 'u2f',
 	},
+	webauthn => {
+	    optional => 1,
+	    type => 'string',
+	    format => $webauthn_format,
+	    description => 'webauthn configuration',
+	},
 	description => {
 	    type => 'string',
 	    description => "Datacenter description. Shown in the web-interface datacenter notes panel."
@@ -224,6 +258,10 @@ sub parse_datacenter_config {
 	$res->{u2f} = PVE::JSONSchema::parse_property_string($u2f_format, $u2f);
     }
 
+    if (my $webauthn = $res->{webauthn}) {
+	$res->{webauthn} = PVE::JSONSchema::parse_property_string($webauthn_format, $webauthn);
+    }
+
     # for backwards compatibility only, new migration property has precedence
     if (defined($res->{migration_unsecure})) {
 	if (defined($res->{migration}->{type})) {
@@ -271,6 +309,11 @@ sub write_datacenter_config {
 	$cfg->{u2f} = PVE::JSONSchema::print_property_string($u2f, $u2f_format);
     }
 
+    if (ref($cfg->{webauthn})) {
+	my $webauthn = $cfg->{webauthn};
+	$cfg->{webauthn} = PVE::JSONSchema::print_property_string($webauthn, $webauthn_format);
+    }
+
     my $comment = '';
     # add description as comment to top of file
     my $description = $cfg->{description} || '';
-- 
2.30.2