]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: ldap: ad: support 'mode' paramter, replacing 'secure'
authorLukas Wagner <l.wagner@proxmox.com>
Thu, 27 Jul 2023 08:57:45 +0000 (10:57 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 4 Sep 2023 16:07:27 +0000 (18:07 +0200)
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
www/manager6/dc/AuthEditLDAP.js

index 3cbb47c9f57ddc435ccbdcef450a113f99722d9c..fe41866146a44039470fcc5f670d42b0279a18fc 100644 (file)
@@ -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();
                        }
                    },
                },
@@ -106,6 +114,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]);
     },
 });
index 9986db8a9b41c8feaa94911f6a0416244a2705a1..f4aecef89499cee1e7893055340ebfa266f2db67 100644 (file)
@@ -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();
                        }
                    },
                },
@@ -106,6 +114,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]);
     },
 });