public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager 1/3] ui: ldap: ad: support 'mode' paramter, replacing 'secure'
@ 2023-07-27  8:57 Lukas Wagner
  2023-07-27  8:57 ` [pve-devel] [PATCH manager 2/3] ui: ldap: ad: fix typo for verify certificate combobox Lukas Wagner
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Lukas Wagner @ 2023-07-27  8:57 UTC (permalink / raw)
  To: pve-devel

The backend has supported the 'mode' parameter for quite a while,
however it has not yet been exposed in the GUI, contrary to PMG
and PBS.

The benefit of 'mode' is that it supports LDAP, LDAPS and LDAP via
STARTTLS, compared to just LDAP/LDAPS for the 'secure' parameter.

The modified AuthEdit{LDAP,AD} panel will now automatically migrate
to the new paramter by hooking into onGetValues/onSetValues.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 www/manager6/dc/AuthEditAD.js   | 43 +++++++++++++++++++++++++++------
 www/manager6/dc/AuthEditLDAP.js | 42 ++++++++++++++++++++++++++------
 2 files changed, 71 insertions(+), 14 deletions(-)

diff --git a/www/manager6/dc/AuthEditAD.js b/www/manager6/dc/AuthEditAD.js
index a1999cb7..bd46faaa 100644
--- a/www/manager6/dc/AuthEditAD.js
+++ b/www/manager6/dc/AuthEditAD.js
@@ -49,18 +49,26 @@ Ext.define('PVE.panel.ADInputPanel', {
 		submitEmptyText: false,
 	    },
 	    {
-		xtype: 'proxmoxcheckbox',
-		fieldLabel: 'SSL',
-		name: 'secure',
-		uncheckedValue: 0,
+		xtype: 'proxmoxKVComboBox',
+		name: 'mode',
+		fieldLabel: gettext('Mode'),
+		editable: false,
+		comboItems: [
+		    ['__default__', Proxmox.Utils.defaultText + ' (LDAP)'],
+		    ['ldap', 'LDAP'],
+		    ['ldap+starttls', 'STARTTLS'],
+		    ['ldaps', 'LDAPS'],
+		],
+		value: '__default__',
+		deleteEmpty: !me.isCreate,
 		listeners: {
 		    change: function(field, newValue) {
 			let verifyCheckbox = field.nextSibling('proxmoxcheckbox[name=verify]');
-			if (newValue === true) {
-			    verifyCheckbox.enable();
-			} else {
+			if (newValue === 'ldap' || newValue === '__default__') {
 			    verifyCheckbox.disable();
 			    verifyCheckbox.setValue(0);
+			} else {
+			    verifyCheckbox.enable();
 			}
 		    },
 		},
@@ -91,6 +99,27 @@ Ext.define('PVE.panel.ADInputPanel', {
 	    delete values.verify;
 	}
 
+	if (!me.isCreate) {
+	    // Delete old `secure` parameter. It has been deprecated in favor to the
+	    // `mode` parameter. Migration happens automatically in `onSetValues`.
+	    Proxmox.Utils.assemble_field_data(values, { 'delete': 'secure' });
+	}
+
+
+	return me.callParent([values]);
+    },
+
+    onSetValues(values) {
+	let me = this;
+
+	if (values.secure !== undefined && !values.mode) {
+	    // If `secure` is set, use it to determine the correct setting for `mode`
+	    // `secure` is later deleted by `onSetValues` .
+	    // In case *both* are set, we simply ignore `secure` and use
+	    // whatever `mode` is set to.
+	    values.mode = values.secure ? 'ldaps' : 'ldap';
+	}
+
 	return me.callParent([values]);
     },
 });
diff --git a/www/manager6/dc/AuthEditLDAP.js b/www/manager6/dc/AuthEditLDAP.js
index 2ce16e58..721ea971 100644
--- a/www/manager6/dc/AuthEditLDAP.js
+++ b/www/manager6/dc/AuthEditLDAP.js
@@ -49,18 +49,26 @@ Ext.define('PVE.panel.LDAPInputPanel', {
 		submitEmptyText: false,
 	    },
 	    {
-		xtype: 'proxmoxcheckbox',
-		fieldLabel: 'SSL',
-		name: 'secure',
-		uncheckedValue: 0,
+		xtype: 'proxmoxKVComboBox',
+		name: 'mode',
+		fieldLabel: gettext('Mode'),
+		editable: false,
+		comboItems: [
+		    ['__default__', Proxmox.Utils.defaultText + ' (LDAP)'],
+		    ['ldap', 'LDAP'],
+		    ['ldap+starttls', 'STARTTLS'],
+		    ['ldaps', 'LDAPS'],
+		],
+		value: '__default__',
+		deleteEmpty: !me.isCreate,
 		listeners: {
 		    change: function(field, newValue) {
 			let verifyCheckbox = field.nextSibling('proxmoxcheckbox[name=verify]');
-			if (newValue === true) {
-			    verifyCheckbox.enable();
-			} else {
+			if (newValue === 'ldap' || newValue === '__default__') {
 			    verifyCheckbox.disable();
 			    verifyCheckbox.setValue(0);
+			} else {
+			    verifyCheckbox.enable();
 			}
 		    },
 		},
@@ -91,6 +99,26 @@ Ext.define('PVE.panel.LDAPInputPanel', {
 	    delete values.verify;
 	}
 
+	if (!me.isCreate) {
+	    // Delete old `secure` parameter. It has been deprecated in favor to the
+	    // `mode` parameter. Migration happens automatically in `onSetValues`.
+	    Proxmox.Utils.assemble_field_data(values, { 'delete': 'secure' });
+	}
+
+	return me.callParent([values]);
+    },
+
+    onSetValues(values) {
+	let me = this;
+
+	if (values.secure !== undefined && !values.mode) {
+	    // If `secure` is set, use it to determine the correct setting for `mode`
+	    // `secure` is later deleted by `onSetValues` .
+	    // In case *both* are set, we simply ignore `secure` and use
+	    // whatever `mode` is set to.
+	    values.mode = values.secure ? 'ldaps' : 'ldap';
+	}
+
 	return me.callParent([values]);
     },
 });
-- 
2.39.2





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-04 16:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-27  8:57 [pve-devel] [PATCH manager 1/3] ui: ldap: ad: support 'mode' paramter, replacing 'secure' Lukas Wagner
2023-07-27  8:57 ` [pve-devel] [PATCH manager 2/3] ui: ldap: ad: fix typo for verify certificate combobox Lukas Wagner
2023-07-27  8:57 ` [pve-devel] [PATCH manager 3/3] ui: ldap: ad: replace occurences of SSL with TLS Lukas Wagner
2023-09-01  7:02 ` [pve-devel] [PATCH manager 1/3] ui: ldap: ad: support 'mode' paramter, replacing 'secure' Lukas Wagner
2023-09-04 16:11 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal