From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@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 1123A74815
 for <pve-devel@lists.proxmox.com>; Fri,  9 Jul 2021 13:43:00 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id EFC8D24BF2
 for <pve-devel@lists.proxmox.com>; Fri,  9 Jul 2021 13:42:29 +0200 (CEST)
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 394E224BB8
 for <pve-devel@lists.proxmox.com>; Fri,  9 Jul 2021 13:42:28 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 0C03040F91
 for <pve-devel@lists.proxmox.com>; Fri,  9 Jul 2021 13:42:28 +0200 (CEST)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri,  9 Jul 2021 13:42:24 +0200
Message-Id: <20210709114226.269670-5-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20210709114226.269670-1-d.csapak@proxmox.com>
References: <20210709114226.269670-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.644 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
Subject: [pve-devel] [PATCH widget-toolkit 4/4] add generic OpenIDInputPanel
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: Fri, 09 Jul 2021 11:43:00 -0000

mostly copied from pve, but includes a realm displayeditfield
as well as the comment field

in contrast to the inputpanel in PVE, this is not extended
from a base input panel (where in pve the comment/realm/default/etc.
fields come from)

we do this, since not all products can define a default or tfa

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/Makefile                 |  1 +
 src/Utils.js                 |  9 ++++
 src/window/AuthEditOpenId.js | 96 ++++++++++++++++++++++++++++++++++++
 3 files changed, 106 insertions(+)
 create mode 100644 src/window/AuthEditOpenId.js

diff --git a/src/Makefile b/src/Makefile
index 0f094c6..41b4dc2 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -73,6 +73,7 @@ JSSRC=					\
 	window/ACMEDomains.js		\
 	window/FileBrowser.js		\
 	window/AuthEditBase.js		\
+	window/AuthEditOpenId.js	\
 	node/APT.js			\
 	node/APTRepositories.js		\
 	node/NetworkEdit.js		\
diff --git a/src/Utils.js b/src/Utils.js
index 42cc02c..167679d 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -1158,6 +1158,15 @@ utilities: {
 	    edit: false,
 	    pwchange: true,
 	},
+	openid: {
+	    name: gettext('OpenID Connect Server'),
+	    ipanel: 'pmxAuthOpenIDPanel',
+	    add: true,
+	    edit: true,
+	    tfa: false,
+	    pwchange: false,
+	    iconCls: 'pmx-itype-icon-openid-logo',
+	},
     },
 
     // to add or change existing for product specific ones
diff --git a/src/window/AuthEditOpenId.js b/src/window/AuthEditOpenId.js
new file mode 100644
index 0000000..499e253
--- /dev/null
+++ b/src/window/AuthEditOpenId.js
@@ -0,0 +1,96 @@
+Ext.define('Proxmox.panel.OpenIDInputPanel', {
+    extend: 'Proxmox.panel.InputPanel',
+    xtype: 'pmxAuthOpenIDPanel',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    type: 'openid',
+
+    onGetValues: function(values) {
+	let me = this;
+
+	if (me.isCreate) {
+	    values.type = me.type;
+	}
+
+	return values;
+    },
+
+    columnT: [
+	{
+	    xtype: 'textfield',
+	    name: 'issuer-url',
+	    fieldLabel: gettext('Issuer URL'),
+	    allowBlank: false,
+	},
+    ],
+
+    column1: [
+	{
+	    xtype: 'pmxDisplayEditField',
+	    name: 'realm',
+	    cbind: {
+		value: '{realm}',
+		editable: '{isCreate}',
+	    },
+	    fieldLabel: gettext('Realm'),
+	    allowBlank: false,
+	},
+	{
+	    xtype: 'proxmoxtextfield',
+	    fieldLabel: gettext('Client ID'),
+	    name: 'client-id',
+	    allowBlank: false,
+	},
+	{
+	    xtype: 'proxmoxtextfield',
+	    fieldLabel: gettext('Client Key'),
+	    cbind: {
+		deleteEmpty: '{!isCreate}',
+	    },
+	    name: 'client-key',
+	},
+    ],
+
+    column2: [
+	{
+	    xtype: 'proxmoxcheckbox',
+	    fieldLabel: gettext('Autocreate Users'),
+	    name: 'autocreate',
+	    value: 0,
+	    cbind: {
+		deleteEmpty: '{!isCreate}',
+	    },
+	},
+	{
+	    xtype: 'pmxDisplayEditField',
+	    name: 'username-claim',
+	    editConfig: {
+		xtype: 'proxmoxKVComboBox',
+	    },
+	    cbind: {
+		value: get => get('isCreate') ? '__default__' : Proxmox.Utils.defaultText,
+		deleteEmpty: '{!isCreate}',
+		editable: '{isCreate}',
+	    },
+	    fieldLabel: gettext('Username Claim'),
+	    comboItems: [
+		['__default__', Proxmox.Utils.defaultText],
+		['subject', 'subject'],
+		['username', 'username'],
+		['email', 'email'],
+	    ],
+	},
+    ],
+
+    columnB: [
+	{
+	    xtype: 'textfield',
+	    name: 'comment',
+	    fieldLabel: gettext('Comment'),
+	    cbind: {
+		deleteEmpty: '{!isCreate}',
+	    },
+	},
+    ],
+});
+
-- 
2.30.2