From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 1/3] ui: ldap: ad: support 'mode' paramter, replacing 'secure'
Date: Thu, 27 Jul 2023 10:57:45 +0200 [thread overview]
Message-ID: <20230727085747.231753-1-l.wagner@proxmox.com> (raw)
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
next reply other threads:[~2023-07-27 8:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 8:57 Lukas Wagner [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230727085747.231753-1-l.wagner@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox